com.brightcove.player.network

## Class DownloadManager

- java.lang.Object
- - com.brightcove.player.network.DownloadManager

- All Implemented Interfaces:
    IDownloadManager

      public class DownloadManager
      extends java.lang.Object
      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 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`.

    - ### Nested classes/interfaces inherited from interface com.brightcove.player.network.IDownloadManager

      `IDownloadManager.IRequest`

  - ### Field Summary

    Fields
    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.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    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.
    `java.util.List<android.app.NotificationChannel>` | `getAllNotificationChannels()` Get all of the notification channels assigned to this DownloadManager instance
    `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.
    `android.app.NotificationChannel` | `getNotificationChannelById(java.lang.String notificationChannelId)` Retrieve the NotificationChannel specified by ID (or null if the NotificationChannel does not exist)
    `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)`
    `void` | `removeNotificationChannelById(java.lang.String notificationChannelId)` Remove the NotificationChannel with the spedified ID from the NotificationManager
    `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.
    `void` | `setNotificationChannel(android.app.NotificationChannel notificationChannel)` Set the specified NotificationChannel This is typically done when use of a customized NotificationChannel (for example, to manage Notification sound settings) is desired.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### downloadListener

          public final com.liulishuo.filedownloader.FileDownloadLargeFileListener downloadListener

      A listener will be used watch download status changes and update the overall download status.

  - ### Method Detail

    - #### getInstance

          @NonNull
          public static DownloadManager getInstance(@NonNull
                                                             android.content.Context context)

      Gets reference to the single instance of the default download manager.
      Parameters:
        `context` - the context of the host application.
      Returns:
        the single instance of the default download manager.

    - #### addListener

          public boolean addListener(@NonNull
                                     java.lang.Long key,
                                     @NonNull
                                     DownloadManager.Listener listener)

    - #### removeListener

          public boolean removeListener(@NonNull
                                        DownloadManager.Listener listener)

    - #### createDownloadRequestSet

          @NonNull
          public io.reactivex.Observable<com.brightcove.player.store.DownloadRequestSet> createDownloadRequestSet(@Nullable
                                                                                                                           RequestConfig requestConfig,
                                                                                                                           long estimatedSize,
                                                                                                                           @NonNull
                                                                                                                           DownloadManager.Listener listener)

      Description copied from interface: `IDownloadManager`
      Creates an empty download request set with the specified estimated size.

      Please note the operation will be carried on a background i/o thread.

      Specified by:
        `createDownloadRequestSet` in interface `IDownloadManager`
      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 changes related to this download request.
      Returns:
        reference to an `Observable` that must subscribed to complete operation and obtain the result.

    - #### enqueueDownload

          @NonNull
          public io.reactivex.Observable<com.brightcove.player.store.DownloadRequestSet> enqueueDownload(@NonNull
                                                                                                                  com.brightcove.player.store.DownloadRequestSet requestSet,
                                                                                                                  @NonNull
                                                                                                                  IDownloadManager.IRequest... requests)

      Description copied from interface: `IDownloadManager`
      Enqueues a set of download requests to the specified request set. The status of the download request set will be more to `DownloadStatus.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.

      Specified by:
        `enqueueDownload` in interface `IDownloadManager`
      Parameters:
        `requestSet` - reference to the
        `requests` - the download requests to be enqueued.
      Returns:
        reference to an `Observable` that must subscribed to complete operation and obtain the result.

    - #### pauseDownload

          @NonNull
          public DownloadStatus pauseDownload(@Nullable
                                                       com.brightcove.player.store.DownloadRequestSet requestSet)

      Description copied from interface: `IDownloadManager`
      Pauses download of the specified request set, if it is not already paused.
      Specified by:
        `pauseDownload` in interface `IDownloadManager`
      Parameters:
        `requestSet` - reference to the download request to be paused.
      Returns:
        the new status of download request set.

    - #### pauseDownload

          @NonNull
          public DownloadStatus pauseDownload(@NonNull
                                                       java.lang.Long requestSetKey)

      Description copied from interface: `IDownloadManager`
      Pauses download of the specified request set, if it is not already paused.
      Specified by:
        `pauseDownload` in interface `IDownloadManager`
      Parameters:
        `requestSetKey` - the unique identifier to the download request.
      Returns:
        the new status of download request set.

    - #### resumeDownload

          @NonNull
          public DownloadStatus resumeDownload(@Nullable
                                                        com.brightcove.player.store.DownloadRequestSet requestSet)

      Description copied from interface: `IDownloadManager`
      Resumes download of the specified request set, if it is currently paused.
      Specified by:
        `resumeDownload` in interface `IDownloadManager`
      Parameters:
        `requestSet` - reference to the download request to be resumed.
      Returns:
        the new status of download request set.

    - #### resumeDownload

          @NonNull
          public DownloadStatus resumeDownload(@NonNull
                                                        java.lang.Long requestSetKey)

      Description copied from interface: `IDownloadManager`
      Resumes download of the specified request set, if it is currently paused.
      Specified by:
        `resumeDownload` in interface `IDownloadManager`
      Parameters:
        `requestSetKey` - the unique identifier to the download request.
      Returns:
        the new status of download request set.

    - #### deleteDownload

          public boolean deleteDownload(@NonNull
                                        java.lang.Long requestSetKey)

      Description copied from interface: `IDownloadManager`
      Cancels all the download requests in the specified set and removes the download request set.
      Specified by:
        `deleteDownload` in interface `IDownloadManager`
      Parameters:
        `requestSetKey` - the unique identifier to the download request.
      Returns:
        true if the request set was found and removed, otherwise false.

    - #### deleteDownload

          public boolean deleteDownload(@Nullable
                                        com.brightcove.player.store.DownloadRequestSet requestSet)

      Description copied from interface: `IDownloadManager`
      Cancels all the download requests in the specified set and removes the download request set.
      Specified by:
        `deleteDownload` in interface `IDownloadManager`
      Parameters:
        `requestSet` - the request set to be cancelled.
      Returns:
        true if the request set was found and removed, otherwise false.

    - #### getDownloadStatus

          @NonNull
          public DownloadStatus getDownloadStatus(@NonNull
                                                           java.lang.Long requestSetKey)

      Description copied from interface: `IDownloadManager`
      Queries the overall download status of the specified download request set.
      Specified by:
        `getDownloadStatus` in interface `IDownloadManager`
      Parameters:
        `requestSetKey` - the unique identifier to the download request.
      Returns:
        the overall download status

    - #### getDownloadStatus

          @NonNull
          public DownloadStatus getDownloadStatus(@Nullable
                                                           com.brightcove.player.store.DownloadRequestSet requestSet)

      Description copied from interface: `IDownloadManager`
      Queries the overall download status of the specified download request set.
      Specified by:
        `getDownloadStatus` in interface `IDownloadManager`
      Parameters:
        `requestSet` - reference to the download request set.
      Returns:
        the overall download status

    - #### setNotificationChannel

          public void setNotificationChannel(@NonNull
                                             android.app.NotificationChannel notificationChannel)

      Set the specified NotificationChannel This is typically done when use of a customized NotificationChannel (for example, to manage Notification sound settings) is desired. Note that setting a custom NotificationChannel will remove this DownloadManager's default NotificationChannel
      Parameters:
        `notificationChannel` - The user-created NotificationChannel object

    - #### getNotificationChannelById

          @Nullable
          public android.app.NotificationChannel getNotificationChannelById(@NonNull
                                                                                      java.lang.String notificationChannelId)

      Retrieve the NotificationChannel specified by ID (or null if the NotificationChannel does not exist)
      Parameters:
        `notificationChannelId` - The NotificationChannel ID
      Returns:
        The NotificationChannel with that ID, or null if the channel is not found

    - #### removeNotificationChannelById

          public void removeNotificationChannelById(@NonNull
                                                    java.lang.String notificationChannelId)

      Remove the NotificationChannel with the spedified ID from the NotificationManager
      Parameters:
        `notificationChannelId` - The ID of the NotificationChannel to remove

    - #### getAllNotificationChannels

          @Nullable
          public java.util.List<android.app.NotificationChannel> getAllNotificationChannels()

      Get all of the notification channels assigned to this DownloadManager instance
      Returns:
        The List of this DownloadManager's NotificationChannels