public class DownloadManager extends java.lang.Object implements IDownloadManager
IDownloadManager that uses an application database to
track the requests. The requests placed in the database will be downloaded asynchronously in a
separate process. Any request sets that have been marked for deletion will be cancelled.| Modifier and Type | Class and Description |
|---|---|
static interface |
DownloadManager.Listener
A listener that can be used to callback notifications about download requests.
|
static class |
DownloadManager.Request
Provides mutable implementation of
IRequest, which can be used to submit
download requests to the IDownloadManager. |
IDownloadManager.IRequest| Modifier and Type | Field and Description |
|---|---|
com.liulishuo.filedownloader.FileDownloadLargeFileListener |
downloadListener
A listener will be used watch download status changes and update the overall download status.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addListener(java.lang.Long key,
DownloadManager.Listener listener) |
io.reactivex.Observable<com.brightcove.player.store.DownloadRequestSet> |
createDownloadRequestSet(RequestConfig requestConfig,
long estimatedSize,
DownloadManager.Listener listener)
Creates an empty download request set with the specified estimated size.
|
boolean |
deleteDownload(com.brightcove.player.store.DownloadRequestSet requestSet)
Cancels all the download requests in the specified set and removes the download request set.
|
boolean |
deleteDownload(java.lang.Long requestSetKey)
Cancels all the download requests in the specified set and removes the download request set.
|
io.reactivex.Observable<com.brightcove.player.store.DownloadRequestSet> |
enqueueDownload(com.brightcove.player.store.DownloadRequestSet requestSet,
IDownloadManager.IRequest... requests)
Enqueues a set of download requests to the specified request set.
|
DownloadStatus |
getDownloadStatus(com.brightcove.player.store.DownloadRequestSet requestSet)
Queries the overall download status of the specified download request set.
|
DownloadStatus |
getDownloadStatus(java.lang.Long requestSetKey)
Queries the overall download status of the specified download request set.
|
static DownloadManager |
getInstance(android.content.Context context)
Gets reference to the single instance of the default download manager.
|
DownloadStatus |
pauseDownload(com.brightcove.player.store.DownloadRequestSet requestSet)
Pauses download of the specified request set, if it is not already paused.
|
DownloadStatus |
pauseDownload(java.lang.Long requestSetKey)
Pauses download of the specified request set, if it is not already paused.
|
boolean |
removeListener(DownloadManager.Listener listener) |
DownloadStatus |
resumeDownload(com.brightcove.player.store.DownloadRequestSet requestSet)
Resumes download of the specified request set, if it is currently paused.
|
DownloadStatus |
resumeDownload(java.lang.Long requestSetKey)
Resumes download of the specified request set, if it is currently paused.
|
public final com.liulishuo.filedownloader.FileDownloadLargeFileListener downloadListener
@NonNull public static DownloadManager getInstance(@NonNull android.content.Context context)
context - the context of the host application.public boolean addListener(@NonNull
java.lang.Long key,
@NonNull
DownloadManager.Listener listener)
public boolean removeListener(@NonNull
DownloadManager.Listener listener)
@NonNull
public io.reactivex.Observable<com.brightcove.player.store.DownloadRequestSet> createDownloadRequestSet(@Nullable
RequestConfig requestConfig,
long estimatedSize,
@NonNull
DownloadManager.Listener listener)
IDownloadManagerPlease note the operation will be carried on a background i/o thread.
createDownloadRequestSet in interface IDownloadManagerrequestConfig - the configuration to be used for handling the download requests.estimatedSize - the estimated total size of the download.listener - reference to the callback listener that must be notified about status changes
related to this download request.Observable that must subscribed to complete operation and
obtain the result.@NonNull
public io.reactivex.Observable<com.brightcove.player.store.DownloadRequestSet> enqueueDownload(@NonNull
com.brightcove.player.store.DownloadRequestSet requestSet,
@NonNull
IDownloadManager.IRequest... requests)
IDownloadManagerDownloadStatus.STATUS_PENDING immediately adding the
requests to the database. The DownloadManager will start to process the download
requests after this call, because of network availability and current download queue load.
Please note the operation will be carried on a background i/o thread.
enqueueDownload in interface IDownloadManagerrequestSet - reference to therequests - the download requests to be enqueued.Observable that must subscribed to complete operation and
obtain the result.@NonNull public DownloadStatus pauseDownload(@Nullable com.brightcove.player.store.DownloadRequestSet requestSet)
IDownloadManagerpauseDownload in interface IDownloadManagerrequestSet - reference to the download request to be paused.@NonNull public DownloadStatus pauseDownload(@NonNull java.lang.Long requestSetKey)
IDownloadManagerpauseDownload in interface IDownloadManagerrequestSetKey - the unique identifier to the download request.@NonNull public DownloadStatus resumeDownload(@Nullable com.brightcove.player.store.DownloadRequestSet requestSet)
IDownloadManagerresumeDownload in interface IDownloadManagerrequestSet - reference to the download request to be resumed.@NonNull public DownloadStatus resumeDownload(@NonNull java.lang.Long requestSetKey)
IDownloadManagerresumeDownload in interface IDownloadManagerrequestSetKey - the unique identifier to the download request.public boolean deleteDownload(@NonNull
java.lang.Long requestSetKey)
IDownloadManagerdeleteDownload in interface IDownloadManagerrequestSetKey - the unique identifier to the download request.public boolean deleteDownload(@Nullable
com.brightcove.player.store.DownloadRequestSet requestSet)
IDownloadManagerdeleteDownload in interface IDownloadManagerrequestSet - the request set to be cancelled.@NonNull public DownloadStatus getDownloadStatus(@NonNull java.lang.Long requestSetKey)
IDownloadManagergetDownloadStatus in interface IDownloadManagerrequestSetKey - the unique identifier to the download request.@NonNull public DownloadStatus getDownloadStatus(@Nullable com.brightcove.player.store.DownloadRequestSet requestSet)
IDownloadManagergetDownloadStatus in interface IDownloadManagerrequestSet - reference to the download request set.