public abstract class FileDownloadListener
extends java.lang.Object
pending(com.liulishuo.filedownloader.BaseDownloadTask, int, int) -> started(com.liulishuo.filedownloader.BaseDownloadTask) -> connected(com.liulishuo.filedownloader.BaseDownloadTask, java.lang.String, boolean, int, int) -> progress(com.liulishuo.filedownloader.BaseDownloadTask, int, int)
-> blockComplete(com.liulishuo.filedownloader.BaseDownloadTask) -> completed(com.liulishuo.filedownloader.BaseDownloadTask)
Maybe over with: paused(com.liulishuo.filedownloader.BaseDownloadTask, int, int)/completed(com.liulishuo.filedownloader.BaseDownloadTask)/error(com.liulishuo.filedownloader.BaseDownloadTask, java.lang.Throwable)/warn(com.liulishuo.filedownloader.BaseDownloadTask)
If the task has already downloaded and exist, you will only receive follow callbacks:
blockComplete(com.liulishuo.filedownloader.BaseDownloadTask) ->completed(com.liulishuo.filedownloader.BaseDownloadTask)| Constructor and Description |
|---|
FileDownloadListener() |
FileDownloadListener(int priority)
Deprecated.
not handle priority any more
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
blockComplete(BaseDownloadTask task)
Unlike other methods in
FileDownloadListener(int), BlockComplete is executed in other
thread than main as default, when you receive this execution, it means has already completed
downloading, but just block the execution of completed(BaseDownloadTask). |
protected abstract void |
completed(BaseDownloadTask task)
Achieve complete ceremony.
|
protected void |
connected(BaseDownloadTask task,
java.lang.String etag,
boolean isContinue,
int soFarBytes,
int totalBytes)
Already connected to the server, and received the Http-response.
|
protected abstract void |
error(BaseDownloadTask task,
java.lang.Throwable e)
Occur a exception, but don't has any chance to retry.
|
protected boolean |
isInvalid()
Whether this listener has already invalidated to receive callbacks.
|
protected abstract void |
paused(BaseDownloadTask task,
int soFarBytes,
int totalBytes)
Task is paused, the vast majority of cases is invoking the
BaseDownloadTask.pause()
manually. |
protected abstract void |
pending(BaseDownloadTask task,
int soFarBytes,
int totalBytes)
Enqueue, and pending, waiting for
started(BaseDownloadTask). |
protected abstract void |
progress(BaseDownloadTask task,
int soFarBytes,
int totalBytes)
Fetching datum from network and Writing to the local disk.
|
protected void |
retry(BaseDownloadTask task,
java.lang.Throwable ex,
int retryingTimes,
int soFarBytes)
Occur a exception and has chance
BaseDownloadTask.setAutoRetryTimes(int) to retry and
start Retry. |
protected void |
started(BaseDownloadTask task)
Finish pending, and start the download runnable.
|
protected abstract void |
warn(BaseDownloadTask task)
There has already had some same Tasks(Same-URL & Same-SavePath) in Pending-Queue or is
running.
|
public FileDownloadListener()
public FileDownloadListener(int priority)
priority - not handle priority any moreprotected boolean isInvalid()
true If you don't want to receive any callbacks for this listener.protected abstract void pending(BaseDownloadTask task, int soFarBytes, int totalBytes)
started(BaseDownloadTask).task - The tasksoFarBytes - Already downloaded and reusable bytes stored in the dbtotalBytes - Total bytes stored in the dbIFileDownloadMessenger.notifyPending(com.liulishuo.filedownloader.message.MessageSnapshot)protected void started(BaseDownloadTask task)
task - Current task.IFileDownloadMessenger.notifyStarted(com.liulishuo.filedownloader.message.MessageSnapshot)protected void connected(BaseDownloadTask task, java.lang.String etag, boolean isContinue, int soFarBytes, int totalBytes)
task - The tasketag - ETagisContinue - Is resume from breakpointsoFarBytes - Number of bytes download so fartotalBytes - Total size of the download in bytesIFileDownloadMessenger.notifyConnected(com.liulishuo.filedownloader.message.MessageSnapshot)protected abstract void progress(BaseDownloadTask task, int soFarBytes, int totalBytes)
task - The tasksoFarBytes - Number of bytes download so fartotalBytes - Total size of the download in bytesIFileDownloadMessenger.notifyProgress(com.liulishuo.filedownloader.message.MessageSnapshot)protected void blockComplete(BaseDownloadTask task) throws java.lang.Throwable
FileDownloadListener(int), BlockComplete is executed in other
thread than main as default, when you receive this execution, it means has already completed
downloading, but just block the execution of completed(BaseDownloadTask). therefore,
you can unzip or do some ending operation before completed(BaseDownloadTask) in
other threads.task - the current taskjava.lang.Throwable - if any throwable is thrown in this method, you will receive the
callback method of error(BaseDownloadTask, Throwable) with the
throwable parameter instead of completed(BaseDownloadTask)IFileDownloadMessenger.notifyBlockComplete(com.liulishuo.filedownloader.message.MessageSnapshot)protected void retry(BaseDownloadTask task, java.lang.Throwable ex, int retryingTimes, int soFarBytes)
BaseDownloadTask.setAutoRetryTimes(int) to retry and
start Retry.task - The taskex - Why retryretryingTimes - How many times will retrysoFarBytes - Number of bytes download so farIFileDownloadMessenger.notifyRetry(com.liulishuo.filedownloader.message.MessageSnapshot)protected abstract void completed(BaseDownloadTask task)
task - The taskIFileDownloadMessenger.notifyCompleted(com.liulishuo.filedownloader.message.MessageSnapshot),
blockComplete(BaseDownloadTask)protected abstract void paused(BaseDownloadTask task, int soFarBytes, int totalBytes)
BaseDownloadTask.pause()
manually.task - The tasksoFarBytes - Number of bytes download so fartotalBytes - Total size of the download in bytesIFileDownloadMessenger.notifyPaused(com.liulishuo.filedownloader.message.MessageSnapshot)protected abstract void error(BaseDownloadTask task, java.lang.Throwable e)
task - The taske - Any throwable on download pipelineIFileDownloadMessenger.notifyError(com.liulishuo.filedownloader.message.MessageSnapshot),
FileDownloadHttpException,
FileDownloadGiveUpRetryException,
FileDownloadOutOfSpaceExceptionprotected abstract void warn(BaseDownloadTask task)
task - The taskIFileDownloadMessenger.notifyWarn(com.liulishuo.filedownloader.message.MessageSnapshot)