命令编写

pull/2/head
lyy 8 years ago
parent 3fd6ff7f70
commit 7ed5d7f449
  1. 1
      downloadutil/src/main/java/com/arialyy/downloadutil/core/DownloadTarget.java
  2. 16
      downloadutil/src/main/java/com/arialyy/downloadutil/core/command/AddCommand.java
  3. 18
      downloadutil/src/main/java/com/arialyy/downloadutil/core/command/CancelCommand.java
  4. 18
      downloadutil/src/main/java/com/arialyy/downloadutil/core/command/GetStateCommand.java
  5. 6
      downloadutil/src/main/java/com/arialyy/downloadutil/core/command/IDownloadCommand.java
  6. 7
      downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StartCommand.java
  7. 18
      downloadutil/src/main/java/com/arialyy/downloadutil/core/command/StopCommand.java

@ -95,6 +95,7 @@ public class DownloadTarget extends IDownloadTarget {
if (task == null) {
task = mExecutePool.getTask(downloadUrl);
}
return task;
}

@ -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);
}
}

@ -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() {
}
}

@ -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() {
}
}

@ -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;
}

@ -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();
}
}

@ -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() {
}
}
Loading…
Cancel
Save