|
|
@ -23,6 +23,9 @@ import com.arialyy.aria.core.command.ICmd; |
|
|
|
import com.arialyy.aria.core.command.normal.CancelCmd; |
|
|
|
import com.arialyy.aria.core.command.normal.CancelCmd; |
|
|
|
import com.arialyy.aria.core.command.normal.NormalCmdFactory; |
|
|
|
import com.arialyy.aria.core.command.normal.NormalCmdFactory; |
|
|
|
import com.arialyy.aria.core.common.RequestEnum; |
|
|
|
import com.arialyy.aria.core.common.RequestEnum; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.DownloadGroupTaskEntity; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.download.DownloadTaskEntity; |
|
|
|
|
|
|
|
import com.arialyy.aria.core.upload.UploadTaskEntity; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
|
import com.arialyy.aria.util.CommonUtil; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -165,10 +168,23 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override public void start() { |
|
|
|
@Override public void start() { |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_START)) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_START, |
|
|
|
|
|
|
|
checkTaskType())) |
|
|
|
.exe(); |
|
|
|
.exe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected int checkTaskType() { |
|
|
|
|
|
|
|
int taskType = 0; |
|
|
|
|
|
|
|
if (mTaskEntity instanceof DownloadTaskEntity) { |
|
|
|
|
|
|
|
taskType = ICmd.TASK_TYPE_DOWNLOAD; |
|
|
|
|
|
|
|
} else if (mTaskEntity instanceof DownloadGroupTaskEntity) { |
|
|
|
|
|
|
|
taskType = ICmd.TASK_TYPE_DOWNLOAD_GROUP; |
|
|
|
|
|
|
|
} else if (mTaskEntity instanceof UploadTaskEntity) { |
|
|
|
|
|
|
|
taskType = ICmd.TASK_TYPE_UPLOAD; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return taskType; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 停止任务 |
|
|
|
* 停止任务 |
|
|
|
* |
|
|
|
* |
|
|
@ -180,7 +196,8 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti |
|
|
|
|
|
|
|
|
|
|
|
@Override public void stop() { |
|
|
|
@Override public void stop() { |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_STOP)) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_STOP, |
|
|
|
|
|
|
|
checkTaskType())) |
|
|
|
.exe(); |
|
|
|
.exe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -189,7 +206,8 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override public void resume() { |
|
|
|
@Override public void resume() { |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_START)) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_START, |
|
|
|
|
|
|
|
checkTaskType())) |
|
|
|
.exe(); |
|
|
|
.exe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -198,7 +216,8 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override public void cancel() { |
|
|
|
@Override public void cancel() { |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
AriaManager.getInstance(AriaManager.APP) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_CANCEL)) |
|
|
|
.setCmd(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_CANCEL, |
|
|
|
|
|
|
|
checkTaskType())) |
|
|
|
.exe(); |
|
|
|
.exe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -207,8 +226,11 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void reTry() { |
|
|
|
public void reTry() { |
|
|
|
List<ICmd> cmds = new ArrayList<>(); |
|
|
|
List<ICmd> cmds = new ArrayList<>(); |
|
|
|
cmds.add(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_STOP)); |
|
|
|
int taskType = checkTaskType(); |
|
|
|
cmds.add(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_START)); |
|
|
|
cmds.add( |
|
|
|
|
|
|
|
CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_STOP, taskType)); |
|
|
|
|
|
|
|
cmds.add(CommonUtil.createNormalCmd(mTargetName, mTaskEntity, NormalCmdFactory.TASK_START, |
|
|
|
|
|
|
|
taskType)); |
|
|
|
AriaManager.getInstance(AriaManager.APP).setCmds(cmds).exe(); |
|
|
|
AriaManager.getInstance(AriaManager.APP).setCmds(cmds).exe(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -220,7 +242,7 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void cancel(boolean removeFile) { |
|
|
|
public void cancel(boolean removeFile) { |
|
|
|
CancelCmd cancelCmd = (CancelCmd) CommonUtil.createNormalCmd(mTargetName, mTaskEntity, |
|
|
|
CancelCmd cancelCmd = (CancelCmd) CommonUtil.createNormalCmd(mTargetName, mTaskEntity, |
|
|
|
NormalCmdFactory.TASK_CANCEL); |
|
|
|
NormalCmdFactory.TASK_CANCEL, checkTaskType()); |
|
|
|
cancelCmd.removeFile = removeFile; |
|
|
|
cancelCmd.removeFile = removeFile; |
|
|
|
AriaManager.getInstance(AriaManager.APP).setCmd(cancelCmd).exe(); |
|
|
|
AriaManager.getInstance(AriaManager.APP).setCmd(cancelCmd).exe(); |
|
|
|
} |
|
|
|
} |
|
|
|