Skip to content
Jacksgong edited this page Apr 23, 2018 · 4 revisions

How to set network thread count?

DownloadDispatcher.setMaxParallelRunningCount(int)

How to set My Own task id Generation Function?

As I know this feature is just for "replace URL for the case of old URL is discard but its data still resumable", so, because of FileDownloader isn't provide database interface, so you can't change the URL saved on the database, so we have to use like idGenerator to handle this case.

But good news on okdownload, it supports edit database, so for that feature, you can easily handle like under way:

final BreakpointStore store = OkDownload.with().breakpoint();
final BreakpointInfo oldTaskInfo = store.get(id);

final DownloadTask newTask = new DownloadTask.Builder(newUrl, file).build();
final newInfo = oldTaskInfo.copyWithReplaceIdAndUrl(newTask.getId(), newUrl);
store.createAndInsert(task);
store.update(newInfo);
store.remove(id);

// then newTask with newUrl will reuse proceed on the oldTaskInfo
newTask.enqueue(listener);

task.pause Callback is missing?

You can use DownloadTask#cancel instead of task.pause, mostly it is the same to the task.pause, and if you have a bunch of tasks need to be paused, please use DownloadTask.cancel(tasks) it has high performance to handle the bunch of tasks.

from task object how to get download size and total size?

I think if you just cast a glance at the sample project, you knew that.

On the FileDownloader the reuse and cache too many references on task are very bad practice because it let task become time sense, we have to handle the complex case of references on the task is changed, and raise tons of bugs for it.

So, on the okdownload, the task will force on its profile.

But we also provide many convenient ways for you to cache download size or total size. the normal case is you can get them from DownloadListener or its BreakpointInfo(because you can touch database data BreakpointInfo and you also can get its data reference on the database from OkDownload.with().breakpoint().get(id) or from DownloadListener callback, so you can get those size from it); but you also can use DownloadTask#addTag or DownloadTask#setTag to cache it to the DownloadTask each time on callbacks of DownloadListener, then get them from DownloadTask#getTag.

How to increase connection count for target task?

Ref to wiki, you just extend DownloadStrategy and overwrite the method of DownloadStrategy#determineBlockCount, and return which block count you want for the task.

What is cancel real doing?