-
Notifications
You must be signed in to change notification settings - Fork 777
Simple Use Guideline
Jacksgong edited this page Apr 6, 2018
·
6 revisions
task = new DownloadTask.Builder(url, parentFile)
.setFilename(filename)
// the minimal interval millisecond for callback progress
.setMinIntervalMillisCallbackProcess(30)
// do re-download even if the task has already been completed in the past.
.setPassIfAlreadyCompleted(false)
.build();
task.enqueue(listener);
// cancel
task.cancel();
// execute task synchronized
task.execute(listener);
// This method is optimize specially for bunch of tasks
DownloadTask.enqueue(tasks, listener);
// cancel, this method is also optmize specially for bunch of tasks
DownloadTask.cancel(tasks);
DownloadContext.Builder builder = new DownloadContext.QueueSet()
.setParentPathFile(parentFile)
.setMinIntervalMillisCallbackProcess(150)
.commit();
builder.bind(url1);
builder.bind(url2).addTag(key, value);
builder.bind(url3).setTag(tag);
builder.setListener(contextListener);
DownloadTask task = new DownloadTask.Builder(url4, parentFile)
.setPriority(10).build();
builder.bindSetTask(task);
DownloadContext context = builder.build();
context.startOnParallel(listener);
// stop
context.stop();
Normally you can get state and info on DownloadListener
.
Status status = StatusUtil.getStatus(task)
status = StatusUtil.getStatus(url, parentPath, null);
status = StatusUtil.getStatus(url, parentPath, filename);
boolean isCompleted = StatusUtil.isCompleted(task);
isCompleted = StatusUtil.isCompleted(url, parentPath, null);
isCompleted = StatusUtil.isCompleted(url, parentPath, filename);
Status completedOrUnknown = StatusUtil.isCompletedOrUnknown(task);
// If you set tag, so just get tag
task.getTag();
task.getTag(xxx);
// Note: the info will be deleted since task is completed download for data health lifecycle
BreakpointInfo info = OkDownload.with().breakpointStore().get(it);
info = StatusUtil.getCurrentInfo(url, parentPath, null);
info = StatusUtil.getCurrentInfo(url, parentPath, filename);
// Since okdownload v1.0.1-SNAPSHOT
// the info reference will be cached on the task refrence even if the task is completed download.
info = task.getInfo();