杏吧 v5.0版本的 MD5 值为:6060d82046650ce71383e136711e525f
以下内容为反编译后的 UploadReceiver.java 源代码,内容仅作参考
package com.arialyy.aria.core.upload;
import android.text.TextUtils;
import com.arialyy.annotations.TaskEnum;
import com.arialyy.aria.core.AriaConfig;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.command.CancelAllCmd;
import com.arialyy.aria.core.command.CmdHelper;
import com.arialyy.aria.core.command.NormalCmdFactory;
import com.arialyy.aria.core.common.ProxyHelper;
import com.arialyy.aria.core.event.EventMsgUtil;
import com.arialyy.aria.core.inf.AbsReceiver;
import com.arialyy.aria.core.inf.ReceiverType;
import com.arialyy.aria.core.queue.UTaskQueue;
import com.arialyy.aria.core.scheduler.TaskInternalListenerInterface;
import com.arialyy.aria.core.scheduler.TaskSchedulers;
import com.arialyy.aria.core.upload.target.FtpBuilderTarget;
import com.arialyy.aria.core.upload.target.FtpNormalTarget;
import com.arialyy.aria.core.upload.target.HttpBuilderTarget;
import com.arialyy.aria.core.upload.target.HttpNormalTarget;
import com.arialyy.aria.core.upload.target.UTargetFactory;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.ComponentUtil;
import java.util.List;
import java.util.Set;
public class UploadReceiver extends AbsReceiver {
public UploadReceiver(Object obj) {
super(obj);
}
public List<UploadEntity> getAllCompleteTask() {
return DbEntity.findDatas(UploadEntity.class, "isGroupChild=? and isComplete=?", "false", "true");
}
public List<UploadEntity> getAllNotCompleteTask() {
return DbEntity.findDatas(UploadEntity.class, "isGroupChild=? and isComplete=?", "false", "false");
}
public UploadEntity getFirstUploadEntity(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
return (UploadEntity) DbEntity.findFirst(UploadEntity.class, "filePath=?", str);
}
public List<UploadEntity> getTaskList() {
return DbEntity.findAllData(UploadEntity.class);
}
@Override
public ReceiverType getType() {
return ReceiverType.UPLOAD;
}
public List<UploadEntity> getURunningTask() {
return UTaskQueue.getInstance().getRunningTask(UploadEntity.class);
}
public UploadEntity getUploadEntity(long j2) {
if (j2 == -1) {
return null;
}
return (UploadEntity) DbEntity.findFirst(UploadEntity.class, "rowid=?", String.valueOf(j2));
}
public HttpBuilderTarget load(String str) {
ComponentUtil.getInstance().checkComponentExist(1);
CheckUtil.checkUploadPathIsEmpty(str);
return (HttpBuilderTarget) UTargetFactory.getInstance().generateBuilderTarget(HttpBuilderTarget.class, str);
}
public FtpBuilderTarget loadFtp(String str) {
ComponentUtil.getInstance().checkComponentExist(2);
CheckUtil.checkUploadPathIsEmpty(str);
return (FtpBuilderTarget) UTargetFactory.getInstance().generateBuilderTarget(FtpBuilderTarget.class, str);
}
@Override
public void register() {
Object obj = this.obj;
if (obj == null) {
ALog.e(this.TAG, String.format("【%s】观察者为空", getTargetName()));
} else if (obj instanceof TaskInternalListenerInterface) {
ProxyHelper.getInstance().checkProxyType(this.obj.getClass());
if (this.obj instanceof UploadTaskListener) {
TaskSchedulers.getInstance().register(this.obj, TaskEnum.UPLOAD);
}
} else {
Set<Integer> checkProxyType = ProxyHelper.getInstance().checkProxyType(this.obj.getClass());
if (checkProxyType != null && !checkProxyType.isEmpty()) {
for (Integer num : checkProxyType) {
if (num.intValue() == ProxyHelper.PROXY_TYPE_UPLOAD) {
TaskSchedulers.getInstance().register(this.obj, TaskEnum.UPLOAD);
}
}
return;
}
ALog.e(this.TAG, "没有Aria的注解方法,详情见:https://aria.laoyuyu.me/aria_doc/other/annotaion_invalid.html");
}
}
public void removeAllTask(boolean z) {
AriaManager ariaManager = AriaManager.getInstance();
CancelAllCmd cancelAllCmd = (CancelAllCmd) CmdHelper.createNormalCmd(new UTaskWrapper(null), NormalCmdFactory.TASK_CANCEL_ALL, 2);
cancelAllCmd.removeFile = z;
EventMsgUtil.getDefault().post(cancelAllCmd);
for (String str : ariaManager.getReceiver().keySet()) {
ariaManager.getReceiver().remove(str);
}
}
@Deprecated
public UploadReceiver setMaxSpeed(int i2) {
AriaConfig.getInstance().getUConfig().setMaxSpeed(i2);
return this;
}
public void stopAllTask() {
EventMsgUtil.getDefault().post(NormalCmdFactory.getInstance().createCmd((AbsTaskWrapper) new UTaskWrapper(null), NormalCmdFactory.TASK_STOP_ALL, 2));
}
public boolean taskExists(String str) {
return DbEntity.checkDataExist(UTaskWrapper.class, "key=?", str);
}
@Override
public void unRegister() {
if (isNeedRmListener()) {
unRegisterListener();
}
AriaManager.getInstance().removeReceiver(this.obj);
}
@Override
public void unRegisterListener() {
if (this.obj == null) {
ALog.e(this.TAG, String.format("【%s】观察者为空", getTargetName()));
return;
}
Set<Integer> set = ProxyHelper.getInstance().mProxyCache.get(this.obj.getClass().getName());
if (set != null) {
for (Integer num : set) {
if (num.intValue() == ProxyHelper.PROXY_TYPE_UPLOAD) {
TaskSchedulers.getInstance().unRegister(this.obj);
}
}
}
}
public List<UploadEntity> getAllCompleteTask(int i2, int i3) {
CheckUtil.checkPageParams(i2, i3);
return DbEntity.findDatas(UploadEntity.class, "isGroupChild=? and downloadPath!='' and isComplete=?", "false", "true");
}
public List<UploadEntity> getAllNotCompleteTask(int i2, int i3) {
CheckUtil.checkPageParams(i2, i3);
return DbEntity.findDatas(UploadEntity.class, i2, i3, "isGroupChild=? and downloadPath!='' and isComplete=?", "false", "false");
}
public List<UploadEntity> getTaskList(int i2, int i3) {
CheckUtil.checkPageParams(i2, i3);
return DbEntity.findDatas(UploadEntity.class, i2, i3, "isGroupChild=? and downloadPath!=''", "false");
}
public List<UploadEntity> getUploadEntity(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
return DbEntity.findDatas(UploadEntity.class, "filePath=?", str);
}
public HttpNormalTarget load(long j2) {
ComponentUtil.getInstance().checkComponentExist(1);
return (HttpNormalTarget) UTargetFactory.getInstance().generateNormalTarget(HttpNormalTarget.class, j2);
}
public FtpNormalTarget loadFtp(long j2) {
ComponentUtil.getInstance().checkComponentExist(2);
return (FtpNormalTarget) UTargetFactory.getInstance().generateNormalTarget(FtpNormalTarget.class, j2);
}
}