use of com.lzy.okserver.download.DownloadTask in project okhttp-OkGo by jeasonlzy.
the class DownloadAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
DownloadTask task = values.get(position);
String tag = createTag(task);
//
task.register(new ListDownloadListener(tag, holder)).register(new LogDownloadListener());
holder.setTag(tag);
holder.setTask(task);
holder.bind();
holder.refresh(task.progress);
}
use of com.lzy.okserver.download.DownloadTask in project okhttp-OkGo by jeasonlzy.
the class OkDownload method startAll.
/**
* 开始所有任务
*/
public void startAll() {
for (Map.Entry<String, DownloadTask> entry : taskMap.entrySet()) {
DownloadTask task = entry.getValue();
if (task == null) {
OkLogger.w("can't find task with tag = " + entry.getKey());
continue;
}
task.start();
}
}
use of com.lzy.okserver.download.DownloadTask in project okhttp-OkGo by jeasonlzy.
the class OkDownload method restore.
/**
* 从数据库中恢复任务
*/
public static DownloadTask restore(Progress progress) {
Map<String, DownloadTask> taskMap = OkDownload.getInstance().getTaskMap();
DownloadTask task = taskMap.get(progress.tag);
if (task == null) {
task = new DownloadTask(progress);
taskMap.put(progress.tag, task);
}
return task;
}
use of com.lzy.okserver.download.DownloadTask in project okhttp-OkGo by jeasonlzy.
the class OkDownload method request.
public static DownloadTask request(String tag, Request<File, ? extends Request> request) {
Map<String, DownloadTask> taskMap = OkDownload.getInstance().getTaskMap();
DownloadTask task = taskMap.get(tag);
if (task == null) {
task = new DownloadTask(tag, request);
taskMap.put(tag, task);
}
return task;
}
use of com.lzy.okserver.download.DownloadTask in project okhttp-OkGo by jeasonlzy.
the class OkDownload method restore.
/**
* 从数据库中恢复任务
*/
public static List<DownloadTask> restore(List<Progress> progressList) {
Map<String, DownloadTask> taskMap = OkDownload.getInstance().getTaskMap();
List<DownloadTask> tasks = new ArrayList<>();
for (Progress progress : progressList) {
DownloadTask task = taskMap.get(progress.tag);
if (task == null) {
task = new DownloadTask(progress);
taskMap.put(progress.tag, task);
}
tasks.add(task);
}
return tasks;
}
Aggregations