-
- All Implemented Interfaces:
-
com.brightcove.player.network.IDownloadManager
public class DownloadManager implements IDownloadManager
Provides an implementation of 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
DownloadManager.Listener
A listener that can be used to callback notifications about download requests.
public class
DownloadManager.Request
Provides mutable implementation of IRequest, which can be used to submitdownload requests to the IDownloadManager.
-
Field Summary
Fields Modifier and Type Field Description private static volatile DownloadManager
instance
private NotificationChannel
notificationChannel
public final FileDownloadLargeFileListener
downloadListener
-
Method Summary
Modifier and Type Method Description static DownloadManager
getInstance(@NonNull() Context context)
Gets reference to the single instance of the default download manager. static DownloadManager
getInstance(@NonNull() Context context)
Gets reference to the single instance of the default download manager. void
setNotificationChannel(@NonNull() NotificationChannel notificationChannel)
Set the specified NotificationChannelThis is typically done when use of a customized NotificationChannel (for example, to manage Notification sound settings) isdesired. boolean
addListener(@NonNull() Long key, @NonNull() DownloadManager.Listener listener)
boolean
removeListener(@NonNull() DownloadManager.Listener listener)
Observable<DownloadRequestSet>
createDownloadRequestSet(@Nullable() RequestConfig requestConfig, long estimatedSize, @NonNull() DownloadManager.Listener listener)
Creates an empty download request set with the specified estimated size. Observable<DownloadRequestSet>
enqueueDownload(@NonNull() DownloadRequestSet requestSet, @NonNull() Array<IDownloadManager.IRequest> requests)
Enqueues a set of download requests to the specified request set. DownloadStatus
pauseDownload(@Nullable() DownloadRequestSet requestSet)
Pauses download of the specified request set, if it is not already paused. DownloadStatus
pauseDownload(@NonNull() Long requestSetKey)
Pauses download of the specified request set, if it is not already paused. DownloadStatus
resumeDownload(@Nullable() DownloadRequestSet requestSet)
Resumes download of the specified request set, if it is currently paused. DownloadStatus
resumeDownload(@NonNull() Long requestSetKey)
Resumes download of the specified request set, if it is currently paused. boolean
deleteDownload(@NonNull() Long requestSetKey)
Cancels all the download requests in the specified set and removes the download request set. boolean
deleteDownload(@Nullable() DownloadRequestSet requestSet)
Cancels all the download requests in the specified set and removes the download request set. DownloadStatus
getDownloadStatus(@NonNull() Long requestSetKey)
Queries the overall download status of the specified download request set. DownloadStatus
getDownloadStatus(@Nullable() DownloadRequestSet requestSet)
Queries the overall download status of the specified download request set. NotificationChannel
getNotificationChannelById(@NonNull() String notificationChannelId)
Retrieve the NotificationChannel specified by ID (or null if the NotificationChannel does not exist) void
removeNotificationChannelById(@NonNull() String notificationChannelId)
Remove the NotificationChannel with the spedified ID from the NotificationManager List<NotificationChannel>
getAllNotificationChannels()
Get all of the notification channels assigned to this DownloadManager instance -
Methods inherited from class com.brightcove.player.network.IDownloadManager
createDownloadRequestSet, deleteDownload, enqueueDownload, getDownloadStatus, getDownloadStatus, pauseDownload, resumeDownload
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getInstance
@NonNull() static DownloadManager getInstance(@NonNull() Context context)
Gets reference to the single instance of the default download manager.
- Parameters:
context
- the context of the host application.
-
getInstance
@NonNull() static DownloadManager getInstance(@NonNull() Context context)
Gets reference to the single instance of the default download manager.
- Parameters:
context
- the context of the host application.
-
setNotificationChannel
void setNotificationChannel(@NonNull() NotificationChannel notificationChannel)
Set the specified NotificationChannelThis is typically done when use of a customized NotificationChannel (for example, to manage Notification sound settings) isdesired.Note that setting a custom NotificationChannel will remove this DownloadManager's default NotificationChannel
- Parameters:
notificationChannel
- The user-created NotificationChannel object
-
addListener
boolean addListener(@NonNull() Long key, @NonNull() DownloadManager.Listener listener)
-
removeListener
boolean removeListener(@NonNull() DownloadManager.Listener listener)
-
createDownloadRequestSet
@NonNull() Observable<DownloadRequestSet> createDownloadRequestSet(@Nullable() RequestConfig requestConfig, long estimatedSize, @NonNull() DownloadManager.Listener listener)
Creates an empty download request set with the specified estimated size.
Please note the operation will be carried on a background i/o thread.
- Parameters:
requestConfig
- 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 changesrelated to this download request.
-
enqueueDownload
@NonNull() Observable<DownloadRequestSet> enqueueDownload(@NonNull() DownloadRequestSet requestSet, @NonNull() Array<IDownloadManager.IRequest> requests)
Enqueues a set of download requests to the specified request set. The status of the downloadrequest set will be more to STATUS_PENDING immediately adding therequests to the database. The DownloadManager will start to process the downloadrequests 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.
- Parameters:
requestSet
- reference to therequests
- the download requests to be enqueued.
-
pauseDownload
@NonNull() DownloadStatus pauseDownload(@Nullable() DownloadRequestSet requestSet)
Pauses download of the specified request set, if it is not already paused.
- Parameters:
requestSet
- reference to the download request to be paused.
-
pauseDownload
@NonNull() DownloadStatus pauseDownload(@NonNull() Long requestSetKey)
Pauses download of the specified request set, if it is not already paused.
- Parameters:
requestSetKey
- the unique identifier to the download request.
-
resumeDownload
@NonNull() DownloadStatus resumeDownload(@Nullable() DownloadRequestSet requestSet)
Resumes download of the specified request set, if it is currently paused.
- Parameters:
requestSet
- reference to the download request to be resumed.
-
resumeDownload
@NonNull() DownloadStatus resumeDownload(@NonNull() Long requestSetKey)
Resumes download of the specified request set, if it is currently paused.
- Parameters:
requestSetKey
- the unique identifier to the download request.
-
deleteDownload
boolean deleteDownload(@NonNull() Long requestSetKey)
Cancels all the download requests in the specified set and removes the download request set.
- Parameters:
requestSetKey
- the unique identifier to the download request.
-
deleteDownload
boolean deleteDownload(@Nullable() DownloadRequestSet requestSet)
Cancels all the download requests in the specified set and removes the download request set.
- Parameters:
requestSet
- the request set to be cancelled.
-
getDownloadStatus
@NonNull() DownloadStatus getDownloadStatus(@NonNull() Long requestSetKey)
Queries the overall download status of the specified download request set.
- Parameters:
requestSetKey
- the unique identifier to the download request.
-
getDownloadStatus
@NonNull() DownloadStatus getDownloadStatus(@Nullable() DownloadRequestSet requestSet)
Queries the overall download status of the specified download request set.
- Parameters:
requestSet
- reference to the download request set.
-
getNotificationChannelById
@Nullable() NotificationChannel getNotificationChannelById(@NonNull() String notificationChannelId)
Retrieve the NotificationChannel specified by ID (or null if the NotificationChannel does not exist)
- Parameters:
notificationChannelId
- The NotificationChannel ID
-
removeNotificationChannelById
void removeNotificationChannelById(@NonNull() String notificationChannelId)
Remove the NotificationChannel with the spedified ID from the NotificationManager
- Parameters:
notificationChannelId
- The ID of the NotificationChannel to remove
-
getAllNotificationChannels
@Nullable() List<NotificationChannel> getAllNotificationChannels()
Get all of the notification channels assigned to this DownloadManager instance
-
-
-
-