-
- All Implemented Interfaces:
-
com.brightcove.player.store.MediaStore
public class OfflineStoreManager extends BaseStore
Store manager can be used to persist data into an application specific private database.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interface
OfflineStoreManager.CanChangeDownloadIdentifier
Any method attempting to call changeDownloadIdentifier must be annotated explicitly withthis annotation.
-
Method Summary
Modifier and Type Method Description static OfflineStoreManager
getInstance(@NonNull() Context context)
Gets reference to the single instance of OfflineStoreManager <E extends IdentifiableEntity> E
refreshEntity(@Nullable() E entity)
Refresh the given entity. <T extends IdentifiableEntity> T
saveEntity(@NonNull() T entity)
Inserts or updates the given entity. OfflineVideo
updateDownloadRequestIdList(@NonNull() String videoId, @Nullable() List<Long> requestIdList, long estimatedSize)
Updates the entity with given unique video identifier to save the current list of downloadrequest identifiers. OfflineVideo
saveOfflineVideo(@NonNull() Video video, @NonNull() File downloadDirectory, @NonNull() DownloadRequestSet requestSet)
Saves the offline video information into the store. OfflineVideo
saveOfflineVideo(Video video)
Updates the entity with given unique video identifier to save the video metadata object,while retaining the previously saved license information. OfflineVideo
saveOfflineLicense(@NonNull() Video video)
Updates the entity with given unique video identifier to save the video license information. OfflineVideo
findOfflineVideo(@NonNull() String videoId)
Finds the first offline video entity with the given video identifier. List<OfflineVideo>
findAllOfflineVideo()
Finds all offline video entities. List<OfflineVideo>
findAllOfflineVideo(int status)
Finds all offline video entities with the specified status boolean
deleteOfflineVideo(@NonNull() String videoId)
Deletes the first offline video entity with the given video identifier. DownloadRequestSet
createDownloadRequestSet(@Nullable() RequestConfig requestConfig, long estimatedSize)
Creates a new blank download request set. DownloadRequestSet
addDownloadRequests(@NonNull() DownloadRequestSet requestSet, @NonNull() Array<IDownloadManager.IRequest> requests)
Creates a new blank download request set. DownloadRequestSet
findDownloadRequestSetByKey(@NonNull() Long key)
Finds a download request set with the specified unique key. Uri
findOfflineAssetUri(@Nullable() Uri uri)
Finds the local URI of a remote asset that has been downloaded successfully. Collection<DownloadRequestSet>
findDownloadRequestSets(@NonNull() Array<Long> requestIds)
Finds the download request sets to which the given requests belong to. boolean
deleteDownloadRequestSet(@NonNull() Long key)
Deletes the specified request set from the store. DownloadRequest
updateDownloadRequestStatusByDownloadId(@NonNull() Long downloadId, int statusCode, int reasonCode, long bytesDownloaded, long actualSize, boolean updateParentRecord)
Updates the status of download request. boolean
updateDownloadRequestSetStatus(DownloadRequestSet requestSet, int statusCode, int reasonCode, DownloadRequest downloadRequest, boolean evaluateAllSegments)
Updates the status of Download Request Set. List<DownloadRequest>
pauseDownloadRequestSet(@NonNull() Long key)
Marks a download request set as paused. DownloadRequestSet
resumeDownloadRequestSet(@NonNull() Long key)
Marks a download request set as waiting to be queued. boolean
updateDownloadId(@NonNull() Long key, Long downloadId)
Sets the download identifier for the request with the specified primary key. OfflineVideo
changeDownloadIdentifier(@NonNull() Video video)
Changes the download identifier associated with given video. List<DownloadRequest>
markRequestSetForRemoval(@NonNull() Long key)
Marks the specified request set for removal. List<DownloadRequest>
findDownloadsToBeQueued(int batchSize, boolean excludeWifiOnly)
Fetches a list of download requests that not have been queued for download by the android.app.DownloadManager. boolean
isCurrentDownloadBatchInProgress()
Checks if the current set of download request are still being processed. int
countDownloadRequestsInState(@NonNull() Long requestSetKey, int statusCode)
Counts the download requests belonging to a DownloadRequestSet with the specified status code. boolean
isDownloadCompleted(@NonNull() Long requestSetKey)
Checks if the DownloadRequestSet is completed. List<DownloadRequest>
findCurrentDownloadBatchInProgress(int batchSize)
Finds the current set of download request which are still being processed. List<DownloadRequestSet>
findCurrentDownloadRequestSetInProgress()
Finds the current set of download request set which are still being processed. static List<Video>
toVideoList(@NonNull() List<OfflineVideo> entityList)
Converts the given list of OfflineVideo objects into a list of Video objects. -
Methods inherited from class com.brightcove.player.store.BaseStore
compact, deleteEntity, deleteOfflineVideo, findOfflineAssetUri, findOfflineVideo, getFileSize, onCreated, onUpgraded, refreshEntity, saveEntity, saveOfflineLicense, saveOfflineVideo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getInstance
static OfflineStoreManager getInstance(@NonNull() Context context)
Gets reference to the single instance of OfflineStoreManager
- Parameters:
context
- reference to the host application context.
-
refreshEntity
@Nullable() <E extends IdentifiableEntity> E refreshEntity(@Nullable() E entity)
Refresh the given entity. This refreshes the already loaded properties in the entity.If no properties are loaded then the default properties will be loaded.
- Parameters:
entity
- reference to the entity to be refreshed.
-
saveEntity
<T extends IdentifiableEntity> T saveEntity(@NonNull() T entity)
Inserts or updates the given entity.
- Parameters:
entity
- the entity to be save.
-
updateDownloadRequestIdList
@Nullable() OfflineVideo updateDownloadRequestIdList(@NonNull() String videoId, @Nullable() List<Long> requestIdList, long estimatedSize)
Updates the entity with given unique video identifier to save the current list of downloadrequest identifiers.
- Parameters:
videoId
- the unique video identifier.requestIdList
- a list of download request identifiers.
-
saveOfflineVideo
OfflineVideo saveOfflineVideo(@NonNull() Video video, @NonNull() File downloadDirectory, @NonNull() DownloadRequestSet requestSet)
Saves the offline video information into the store.
- Parameters:
video
- the video information to be saved.downloadDirectory
- the download directory for this video.requestSet
- the download request set related to this video.
-
saveOfflineVideo
@NonNull() OfflineVideo saveOfflineVideo(Video video)
Updates the entity with given unique video identifier to save the video metadata object,while retaining the previously saved license information.
- Parameters:
video
- the video to be saved.
-
saveOfflineLicense
@NonNull() OfflineVideo saveOfflineLicense(@NonNull() Video video)
Updates the entity with given unique video identifier to save the video license information.
- Parameters:
video
- the video to be saved.
-
findOfflineVideo
@Nullable() OfflineVideo findOfflineVideo(@NonNull() String videoId)
Finds the first offline video entity with the given video identifier.
- Parameters:
videoId
- the unique video identifier.
-
findAllOfflineVideo
@NonNull() List<OfflineVideo> findAllOfflineVideo()
Finds all offline video entities.
-
findAllOfflineVideo
@NonNull() List<OfflineVideo> findAllOfflineVideo(int status)
Finds all offline video entities with the specified status
-
deleteOfflineVideo
boolean deleteOfflineVideo(@NonNull() String videoId)
Deletes the first offline video entity with the given video identifier.
- Parameters:
videoId
- the unique video identifier.
-
createDownloadRequestSet
@NonNull() DownloadRequestSet createDownloadRequestSet(@Nullable() RequestConfig requestConfig, long estimatedSize)
Creates a new blank download request set.
-
addDownloadRequests
@NonNull() DownloadRequestSet addDownloadRequests(@NonNull() DownloadRequestSet requestSet, @NonNull() Array<IDownloadManager.IRequest> requests)
Creates a new blank download request set.
-
findDownloadRequestSetByKey
@Nullable() DownloadRequestSet findDownloadRequestSetByKey(@NonNull() Long key)
Finds a download request set with the specified unique key.
- Parameters:
key
- the primary key of the request set.
-
findOfflineAssetUri
@Nullable() Uri findOfflineAssetUri(@Nullable() Uri uri)
Finds the local URI of a remote asset that has been downloaded successfully.
- Parameters:
uri
- the remote URI to the asset.
-
findDownloadRequestSets
Collection<DownloadRequestSet> findDownloadRequestSets(@NonNull() Array<Long> requestIds)
Finds the download request sets to which the given requests belong to.
- Parameters:
requestIds
- an array of one or more download requests.
-
deleteDownloadRequestSet
boolean deleteDownloadRequestSet(@NonNull() Long key)
Deletes the specified request set from the store.
- Parameters:
key
- the primary key of the request set to be deleted.
-
updateDownloadRequestStatusByDownloadId
@Nullable() DownloadRequest updateDownloadRequestStatusByDownloadId(@NonNull() Long downloadId, int statusCode, int reasonCode, long bytesDownloaded, long actualSize, boolean updateParentRecord)
Updates the status of download request.
- Parameters:
downloadId
- the unique identifier of the download request that caused the status change.statusCode
- the new status of the download.reasonCode
- the reason code for the new status, if any.bytesDownloaded
- the number of bytes downloaded so far.actualSize
- the total size of the download.updateParentRecord
- true to update the DownloadRequestSet parent record.
-
updateDownloadRequestSetStatus
boolean updateDownloadRequestSetStatus(DownloadRequestSet requestSet, int statusCode, int reasonCode, DownloadRequest downloadRequest, boolean evaluateAllSegments)
Updates the status of Download Request Set.
- Parameters:
requestSet
- the Download Request SetstatusCode
- the new status of the download segment.reasonCode
- the reason code for the new status, if any.downloadRequest
- the new segment Download RequestevaluateAllSegments
- if true, it makes sure to evaluate all download request segments to get the overall status.
-
pauseDownloadRequestSet
@NonNull() List<DownloadRequest> pauseDownloadRequestSet(@NonNull() Long key)
Marks a download request set as paused.
- Parameters:
key
- the primary key of the request set to be paused.
-
resumeDownloadRequestSet
@Nullable() DownloadRequestSet resumeDownloadRequestSet(@NonNull() Long key)
Marks a download request set as waiting to be queued.
- Parameters:
key
- the primary key of the request set to be paused.
-
updateDownloadId
boolean updateDownloadId(@NonNull() Long key, Long downloadId)
Sets the download identifier for the request with the specified primary key.
- Parameters:
key
- the primary key of the request to be updated.downloadId
- the unique identifier to the download request in the android.app.DownloadManager
-
changeDownloadIdentifier
@Nullable() OfflineVideo changeDownloadIdentifier(@NonNull() Video video)
Changes the download identifier associated with given video. This method is intended forinternal use only. Please do not call this in the application project.
- Parameters:
video
- reference to the video.
-
markRequestSetForRemoval
@NonNull() List<DownloadRequest> markRequestSetForRemoval(@NonNull() Long key)
Marks the specified request set for removal. A request set that has been marked for removalwill not be queued or checked for further status changes. Any download requests in the setthat has been queued already will be removed. The request set itself will be deleted once allthe requests have been removed.
- Parameters:
key
- the primary key of the request set to be updated.
-
findDownloadsToBeQueued
@NonNull() List<DownloadRequest> findDownloadsToBeQueued(int batchSize, boolean excludeWifiOnly)
Fetches a list of download requests that not have been queued for download by the android.app.DownloadManager.
- Parameters:
batchSize
- the maximum number of entities to fetch.excludeWifiOnly
- true if the requests that allowed only on wifi networks must be excluded, otherwise false.
-
isCurrentDownloadBatchInProgress
boolean isCurrentDownloadBatchInProgress()
Checks if the current set of download request are still being processed.
-
countDownloadRequestsInState
int countDownloadRequestsInState(@NonNull() Long requestSetKey, int statusCode)
Counts the download requests belonging to a DownloadRequestSet with the specified status code.
- Parameters:
requestSetKey
- the Download Request Set key.statusCode
- the status code.
-
isDownloadCompleted
boolean isDownloadCompleted(@NonNull() Long requestSetKey)
Checks if the DownloadRequestSet is completed.
- Parameters:
requestSetKey
- the Download Request Set key.
-
findCurrentDownloadBatchInProgress
List<DownloadRequest> findCurrentDownloadBatchInProgress(int batchSize)
Finds the current set of download request which are still being processed.
- Parameters:
batchSize
- the maximum number of entities to fetch
-
findCurrentDownloadRequestSetInProgress
List<DownloadRequestSet> findCurrentDownloadRequestSetInProgress()
Finds the current set of download request set which are still being processed.
-
toVideoList
static List<Video> toVideoList(@NonNull() List<OfflineVideo> entityList)
Converts the given list of OfflineVideo objects into a list of Video objects.
- Parameters:
entityList
- the list to be converted.
-
-
-
-