Java Code Examples for com.liulishuo.filedownloader.util.FileDownloadUtils#findDownloadTaskAdapter()
The following examples show how to use
com.liulishuo.filedownloader.util.FileDownloadUtils#findDownloadTaskAdapter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileDownloadMonitor.java From okdownload with Apache License 2.0 | 5 votes |
@Override public void taskStart(DownloadTask task) { final DownloadTaskAdapter downloadTaskAdapter = FileDownloadUtils.findDownloadTaskAdapter(task); if (downloadTaskAdapter != null) { onTaskBegin(downloadTaskAdapter); } }
Example 2
Source File: FileDownloadMonitor.java From okdownload with Apache License 2.0 | 5 votes |
@Override public void taskDownloadFromBeginning( @NonNull DownloadTask task, @NonNull BreakpointInfo info, @Nullable ResumeFailedCause cause) { final DownloadTaskAdapter downloadTaskAdapter = FileDownloadUtils.findDownloadTaskAdapter(task); if (downloadTaskAdapter != null) { onRequestStart(downloadTaskAdapter); onTaskStarted(downloadTaskAdapter); } }
Example 3
Source File: FileDownloadMonitor.java From okdownload with Apache License 2.0 | 5 votes |
@Override public void taskEnd(DownloadTask task, EndCause cause, @Nullable Exception realCause) { final DownloadTaskAdapter downloadTaskAdapter = FileDownloadUtils.findDownloadTaskAdapter(task); if (downloadTaskAdapter != null) { onTaskOver(downloadTaskAdapter); } }
Example 4
Source File: CompatListenerAssist.java From okdownload with Apache License 2.0 | 5 votes |
public void taskStart(@NonNull DownloadTask task) { final DownloadTaskAdapter downloadTaskAdapter = FileDownloadUtils.findDownloadTaskAdapter(task); if (downloadTaskAdapter == null) return; final long soFarBytes = downloadTaskAdapter.getSoFarBytesInLong(); final long totalBytes = downloadTaskAdapter.getTotalBytesInLong(); callback.pending(downloadTaskAdapter, soFarBytes, totalBytes); callback.started(downloadTaskAdapter); }
Example 5
Source File: CompatListenerAssist.java From okdownload with Apache License 2.0 | 5 votes |
public void connectStart(DownloadTask task) { if (taskConnected.compareAndSet(false, true)) { final DownloadTaskAdapter downloadTaskAdapter = FileDownloadUtils.findDownloadTaskAdapter(task); if (downloadTaskAdapter == null) return; final long soFarBytes = downloadTaskAdapter.getSoFarBytesInLong(); final long totalBytes = downloadTaskAdapter.getTotalBytesInLong(); downloadTaskAdapter.getProgressAssist().initSofarBytes(soFarBytes); downloadTaskAdapter.getProgressAssist().calculateCallbackMinIntervalBytes(totalBytes); callback.connected(downloadTaskAdapter, etag, resumable, soFarBytes, totalBytes); } }
Example 6
Source File: CompatListenerAssist.java From okdownload with Apache License 2.0 | 5 votes |
public void fetchProgress(@NonNull DownloadTask task, long increaseBytes) { final DownloadTaskAdapter downloadTaskAdapter = FileDownloadUtils.findDownloadTaskAdapter(task); if (downloadTaskAdapter == null) return; downloadTaskAdapter.getProgressAssist() .onProgress(downloadTaskAdapter, increaseBytes, callback); }
Example 7
Source File: CompatListenerAssist.java From okdownload with Apache License 2.0 | 5 votes |
public void taskEnd(@NonNull DownloadTask task, @NonNull EndCause cause, @Nullable Exception realCause) { final DownloadTaskAdapter downloadTaskAdapter = FileDownloadUtils.findDownloadTaskAdapter(task); if (downloadTaskAdapter == null) return; downloadTaskAdapter.getProgressAssist().clearProgress(); exception = realCause; switch (cause) { case PRE_ALLOCATE_FAILED: case ERROR: handleError(downloadTaskAdapter, realCause); break; case CANCELED: handleCanceled(downloadTaskAdapter); break; case FILE_BUSY: case SAME_TASK_BUSY: handleWarn(downloadTaskAdapter, cause, realCause); break; case COMPLETED: handleComplete(downloadTaskAdapter); break; default: break; } onTaskFinish(downloadTaskAdapter); }