diff --git a/downloadutil/src/main/java/com/arialyy/downloadutil/core/DownloadTarget.java b/downloadutil/src/main/java/com/arialyy/downloadutil/core/DownloadTarget.java index 7b23b076..e3cba753 100644 --- a/downloadutil/src/main/java/com/arialyy/downloadutil/core/DownloadTarget.java +++ b/downloadutil/src/main/java/com/arialyy/downloadutil/core/DownloadTarget.java @@ -95,6 +95,7 @@ public class DownloadTarget extends IDownloadTarget { if (task == null) { task = mExecutePool.getTask(downloadUrl); } + return task; } diff --git a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/AddCommand.java b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/AddCommand.java index 4fe33bb4..30c9a732 100644 --- a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/AddCommand.java +++ b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/AddCommand.java @@ -1,5 +1,7 @@ package com.arialyy.downloadutil.core.command; +import android.support.annotation.NonNull; + import com.arialyy.downloadutil.core.IDownloadTarget; /** @@ -7,12 +9,22 @@ import com.arialyy.downloadutil.core.IDownloadTarget; * 添加任务的命令 */ public class AddCommand extends IDownloadCommand { - public AddCommand(IDownloadTarget target) { + String mDownloadUrl, mDownloadPath; + + /** + * + * @param target 下载调度器 + * @param downloadUrl 下载链接 + * @param downloadPath 文件保存地址 + */ + public AddCommand(@NonNull IDownloadTarget target, String downloadUrl, String downloadPath) { super(target); + mDownloadUrl = downloadUrl; + mDownloadPath = downloadPath; } @Override public void executeComment() { - + target.createTask(mDownloadUrl, mDownloadPath); } } diff --git a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/CancelCommand.java b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/CancelCommand.java new file mode 100644 index 00000000..2cd79a89 --- /dev/null +++ b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/CancelCommand.java @@ -0,0 +1,18 @@ +package com.arialyy.downloadutil.core.command; + +import com.arialyy.downloadutil.core.IDownloadTarget; + +/** + * Created by lyy on 2016/9/20. + * 取消命令 + */ +public class CancelCommand extends IDownloadCommand{ + public CancelCommand(IDownloadTarget target) { + super(target); + } + + @Override + public void executeComment() { + + } +} diff --git a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/GetStateCommand.java b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/GetStateCommand.java new file mode 100644 index 00000000..dc46380d --- /dev/null +++ b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/GetStateCommand.java @@ -0,0 +1,18 @@ +package com.arialyy.downloadutil.core.command; + +import com.arialyy.downloadutil.core.IDownloadTarget; + +/** + * Created by lyy on 2016/9/20. + * 获取下载状态的命令 + */ +public class GetStateCommand extends IDownloadCommand { + public GetStateCommand(IDownloadTarget target) { + super(target); + } + + @Override + public void executeComment() { + + } +} diff --git a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/IDownloadCommand.java b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/IDownloadCommand.java index 5a04c40b..d96c6d4c 100644 --- a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/IDownloadCommand.java +++ b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/IDownloadCommand.java @@ -1,5 +1,7 @@ package com.arialyy.downloadutil.core.command; +import android.support.annotation.NonNull; + import com.arialyy.downloadutil.core.DownloadTarget; import com.arialyy.downloadutil.core.IDownloadTarget; @@ -10,9 +12,9 @@ import java.util.List; * 下载命令 */ public abstract class IDownloadCommand { - private IDownloadTarget target; + protected IDownloadTarget target; - public IDownloadCommand(IDownloadTarget target) { + public IDownloadCommand(@NonNull IDownloadTarget target) { this.target = target; } diff --git a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StartCommand.java b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StartCommand.java index 2892eaed..f06991ed 100644 --- a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StartCommand.java +++ b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StartCommand.java @@ -1,18 +1,21 @@ package com.arialyy.downloadutil.core.command; +import android.support.annotation.NonNull; + import com.arialyy.downloadutil.core.IDownloadTarget; +import com.arialyy.downloadutil.core.Task; /** * Created by lyy on 2016/8/22. * 开始命令 */ public class StartCommand extends IDownloadCommand{ - public StartCommand(IDownloadTarget target) { + public StartCommand(@NonNull IDownloadTarget target) { super(target); } @Override public void executeComment() { - +// target.startTask(); } } diff --git a/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StopCommand.java b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StopCommand.java new file mode 100644 index 00000000..216607ca --- /dev/null +++ b/downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StopCommand.java @@ -0,0 +1,18 @@ +package com.arialyy.downloadutil.core.command; + +import com.arialyy.downloadutil.core.IDownloadTarget; + +/** + * Created by lyy on 2016/9/20. + * 停止命令 + */ +public class StopCommand extends IDownloadCommand { + public StopCommand(IDownloadTarget target) { + super(target); + } + + @Override + public void executeComment() { + + } +}