public abstract class FileDownloadNotificationListener extends FileDownloadListener
| Constructor and Description |
|---|
FileDownloadNotificationListener(FileDownloadNotificationHelper helper) |
| Modifier and Type | Method and Description |
|---|---|
void |
addNotificationItem(BaseDownloadTask task) |
void |
addNotificationItem(int downloadId) |
protected void |
blockComplete(BaseDownloadTask task)
Unlike other methods in
FileDownloadListener.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 FileDownloadListener.completed(BaseDownloadTask). |
protected void |
completed(BaseDownloadTask task)
Achieve complete ceremony.
|
protected abstract BaseNotificationItem |
create(BaseDownloadTask task) |
void |
destroyNotification(BaseDownloadTask task)
The notification item with the
task is told to destroy. |
protected boolean |
disableNotification(BaseDownloadTask task) |
protected void |
error(BaseDownloadTask task,
Throwable e)
Occur a exception, but don't has any chance to retry.
|
FileDownloadNotificationHelper |
getHelper() |
protected boolean |
interceptCancel(BaseDownloadTask task,
BaseNotificationItem notificationItem) |
protected void |
paused(BaseDownloadTask task,
int soFarBytes,
int totalBytes)
Task is paused, the vast majority of cases is invoking the
BaseDownloadTask.pause()
manually. |
protected void |
pending(BaseDownloadTask task,
int soFarBytes,
int totalBytes)
Enqueue, and pending, waiting for
FileDownloadListener.started(BaseDownloadTask). |
protected void |
progress(BaseDownloadTask task,
int soFarBytes,
int totalBytes)
Fetching datum from network and Writing to the local disk.
|
protected void |
retry(BaseDownloadTask task,
Throwable ex,
int retryingTimes,
int soFarBytes)
Occur a exception and has chance
BaseDownloadTask.setAutoRetryTimes(int) to retry and
start Retry. |
void |
showIndeterminate(BaseDownloadTask task) |
void |
showProgress(BaseDownloadTask task,
int soFarBytes,
int totalBytes) |
protected void |
started(BaseDownloadTask task)
Finish pending, and start the download runnable.
|
protected void |
warn(BaseDownloadTask task)
There has already had some same Tasks(Same-URL & Same-SavePath) in Pending-Queue or is
running.
|
connected, isInvalidpublic FileDownloadNotificationListener(FileDownloadNotificationHelper helper)
public FileDownloadNotificationHelper getHelper()
public void addNotificationItem(int downloadId)
public void addNotificationItem(BaseDownloadTask task)
public void destroyNotification(BaseDownloadTask task)
task is told to destroy.task - The task used to identify the will be destroyed notification item.public void showIndeterminate(BaseDownloadTask task)
public void showProgress(BaseDownloadTask task, int soFarBytes, int totalBytes)
protected abstract BaseNotificationItem create(BaseDownloadTask task)
task - The task used to bind with the will be created notification item.task.protected boolean interceptCancel(BaseDownloadTask task, BaseNotificationItem notificationItem)
task - The task.notificationItem - The notification item.true if you want to survive the notification item, and we will don't cancel
the relate notification from the notification panel when the relate task is finished,
false otherwise.
Default: false
destroyNotification(BaseDownloadTask)protected boolean disableNotification(BaseDownloadTask task)
task - The task.true if you want to disable the internal notification lifecycle, and in this
case all method about the notification will be invalid, false otherwise.
Default: false
protected void pending(BaseDownloadTask task, int soFarBytes, int totalBytes)
FileDownloadListenerFileDownloadListener.started(BaseDownloadTask).pending in class FileDownloadListenertask - 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)
FileDownloadListenerstarted in class FileDownloadListenertask - Current task.IFileDownloadMessenger.notifyStarted(com.liulishuo.filedownloader.message.MessageSnapshot)protected void progress(BaseDownloadTask task, int soFarBytes, int totalBytes)
FileDownloadListenerprogress in class FileDownloadListenertask - The tasksoFarBytes - Number of bytes download so fartotalBytes - Total size of the download in bytesIFileDownloadMessenger.notifyProgress(com.liulishuo.filedownloader.message.MessageSnapshot)protected void retry(BaseDownloadTask task, Throwable ex, int retryingTimes, int soFarBytes)
FileDownloadListenerBaseDownloadTask.setAutoRetryTimes(int) to retry and
start Retry.retry in class FileDownloadListenertask - The taskex - Why retryretryingTimes - How many times will retrysoFarBytes - Number of bytes download so farIFileDownloadMessenger.notifyRetry(com.liulishuo.filedownloader.message.MessageSnapshot)protected void blockComplete(BaseDownloadTask task)
FileDownloadListenerFileDownloadListener.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 FileDownloadListener.completed(BaseDownloadTask). therefore,
you can unzip or do some ending operation before FileDownloadListener.completed(BaseDownloadTask) in
other threads.blockComplete in class FileDownloadListenertask - the current taskIFileDownloadMessenger.notifyBlockComplete(com.liulishuo.filedownloader.message.MessageSnapshot)protected void completed(BaseDownloadTask task)
FileDownloadListenercompleted in class FileDownloadListenertask - The taskIFileDownloadMessenger.notifyCompleted(com.liulishuo.filedownloader.message.MessageSnapshot),
FileDownloadListener.blockComplete(BaseDownloadTask)protected void paused(BaseDownloadTask task, int soFarBytes, int totalBytes)
FileDownloadListenerBaseDownloadTask.pause()
manually.paused in class FileDownloadListenertask - The tasksoFarBytes - Number of bytes download so fartotalBytes - Total size of the download in bytesIFileDownloadMessenger.notifyPaused(com.liulishuo.filedownloader.message.MessageSnapshot)protected void error(BaseDownloadTask task, Throwable e)
FileDownloadListenererror in class FileDownloadListenertask - The taske - Any throwable on download pipelineIFileDownloadMessenger.notifyError(com.liulishuo.filedownloader.message.MessageSnapshot),
FileDownloadHttpException,
FileDownloadGiveUpRetryException,
FileDownloadOutOfSpaceExceptionprotected void warn(BaseDownloadTask task)
FileDownloadListenerwarn in class FileDownloadListenertask - The taskIFileDownloadMessenger.notifyWarn(com.liulishuo.filedownloader.message.MessageSnapshot)