控制命令
This commit is contained in:
@ -15,26 +15,31 @@ public class DownloadTarget extends IDownloadTarget {
|
|||||||
private static volatile DownloadTarget INSTANCE = null;
|
private static volatile DownloadTarget INSTANCE = null;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public static DownloadTarget getInstance() {
|
public static DownloadTarget getInstance(Context context) {
|
||||||
|
// if (INSTANCE == null) {
|
||||||
|
// Log.e(TAG, "请在Application中调用DownloadTarget.init()方法注册下载器");
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
Log.e(TAG, "请在Application中调用DownloadTarget.init()方法注册下载器");
|
synchronized (LOCK) {
|
||||||
return null;
|
INSTANCE = new DownloadTarget(context.getApplicationContext());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 初始化下载器
|
// * 初始化下载器
|
||||||
*
|
// *
|
||||||
* @param context 全局Context
|
// * @param context 全局Context
|
||||||
*/
|
// */
|
||||||
public static void init(Context context) {
|
// public static void init(Context context) {
|
||||||
if (INSTANCE == null) {
|
// if (INSTANCE == null) {
|
||||||
synchronized (LOCK) {
|
// synchronized (LOCK) {
|
||||||
INSTANCE = new DownloadTarget(context);
|
// INSTANCE = new DownloadTarget(context.getApplicationContext());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private DownloadTarget() {
|
private DownloadTarget() {
|
||||||
super();
|
super();
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.arialyy.downloadutil.core.command;
|
||||||
|
|
||||||
|
import com.arialyy.downloadutil.core.IDownloadTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by lyy on 2016/8/22.
|
||||||
|
* 添加任务的命令
|
||||||
|
*/
|
||||||
|
public class AddCommand extends IDownloadCommand {
|
||||||
|
public AddCommand(IDownloadTarget target) {
|
||||||
|
super(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeComment() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.arialyy.downloadutil.core.command;
|
||||||
|
|
||||||
|
import com.arialyy.downloadutil.core.DownloadTarget;
|
||||||
|
import com.arialyy.downloadutil.core.IDownloadTarget;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by lyy on 2016/8/22.
|
||||||
|
* 下载命令
|
||||||
|
*/
|
||||||
|
public abstract class IDownloadCommand {
|
||||||
|
private IDownloadTarget target;
|
||||||
|
|
||||||
|
public IDownloadCommand(IDownloadTarget target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行命令
|
||||||
|
*/
|
||||||
|
public abstract void executeComment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置下载器
|
||||||
|
*
|
||||||
|
* @param downloadTarget {@link IDownloadTarget}
|
||||||
|
*/
|
||||||
|
public void setDownloadTarget(IDownloadTarget downloadTarget) {
|
||||||
|
target = downloadTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.arialyy.downloadutil.core.command;
|
||||||
|
|
||||||
|
import com.arialyy.downloadutil.core.IDownloadTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by lyy on 2016/8/22.
|
||||||
|
* 开始命令
|
||||||
|
*/
|
||||||
|
public class StartCommand extends IDownloadCommand{
|
||||||
|
public StartCommand(IDownloadTarget target) {
|
||||||
|
super(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeComment() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user