parent
aeb1820079
commit
78b76f5399
@ -0,0 +1,33 @@ |
||||
package com.arialyy.downloadutil.core; |
||||
|
||||
import com.arialyy.downloadutil.core.inf.IDownloader; |
||||
import com.arialyy.downloadutil.core.inf.ITask; |
||||
import com.arialyy.downloadutil.core.pool.CachePool; |
||||
import com.arialyy.downloadutil.core.pool.ExecutePool; |
||||
|
||||
/** |
||||
* Created by lyy on 2016/8/16. |
||||
* 任务下载器,提供抽象的方法供具体的实现类操作 |
||||
*/ |
||||
public abstract class DownloadTarget implements IDownloader, ITask { |
||||
protected CachePool mCachePool = CachePool.getInstance(); |
||||
protected ExecutePool mExecutePool = ExecutePool.getInstance(); |
||||
|
||||
/** |
||||
* 获取当前运行的任务数 |
||||
* |
||||
* @return 当前正在执行的任务数 |
||||
*/ |
||||
public int getCurrentTaskNum() { |
||||
return mExecutePool.size(); |
||||
} |
||||
|
||||
/** |
||||
* 获取缓存任务数 |
||||
* |
||||
* @return 获取缓存的任务数 |
||||
*/ |
||||
public int getCacheTaskNum() { |
||||
return mCachePool.size(); |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
package com.arialyy.downloadutil.core.inf; |
||||
|
||||
import com.arialyy.downloadutil.core.Task; |
||||
|
||||
/** |
||||
* Created by lyy on 2016/8/16. |
||||
* 下载功能接口 |
||||
*/ |
||||
public interface IDownloader { |
||||
/** |
||||
* 开始任务 |
||||
* |
||||
* @param task {@link Task} |
||||
*/ |
||||
public void startTask(Task task); |
||||
|
||||
/** |
||||
* 停止任务 |
||||
* |
||||
* @param task {@link Task} |
||||
*/ |
||||
public void stopTask(Task task); |
||||
|
||||
/** |
||||
* 取消任务 |
||||
* |
||||
* @param task {@link Task} |
||||
*/ |
||||
public void cancelTask(Task task); |
||||
|
||||
} |
@ -0,0 +1,34 @@ |
||||
package com.arialyy.downloadutil.core.inf; |
||||
|
||||
import com.arialyy.downloadutil.core.Task; |
||||
|
||||
/** |
||||
* Created by lyy on 2016/8/16. |
||||
* 任务功能接口 |
||||
*/ |
||||
public interface ITask { |
||||
|
||||
/** |
||||
* 创建一个新的下载任务 |
||||
* |
||||
* @param downloadUrl 下载链接 |
||||
* @param downloadPath 保存路径 |
||||
*/ |
||||
public void createTask(String downloadUrl, String downloadPath); |
||||
|
||||
/** |
||||
* 通过下载链接从缓存池或任务池搜索下载任务 |
||||
* |
||||
* @param downloadUrl 下载链接 |
||||
* @return {@link Task} |
||||
*/ |
||||
public Task searchTask(String downloadUrl); |
||||
|
||||
/** |
||||
* 通过下载链接搜索下载任务 |
||||
* |
||||
* @param downloadUrl 下载链接 |
||||
* @return {@link com.arialyy.downloadutil.entity.DownloadEntity#STATE_FAIL} |
||||
*/ |
||||
public int getTaskState(String downloadUrl); |
||||
} |
Loading…
Reference in new issue