Package com.brightcove.player.network
Class DownloadStatus
java.lang.Object
com.brightcove.player.network.DownloadStatus
- All Implemented Interfaces:
android.os.Parcelable
Download status describes the current status of a download request.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceThe list of possible reasons code that will be set whenDownloadStatus.StatusCodeis eitherSTATUS_RETRYorSTATUS_FAILED.static @interfaceThe list of possible status values forDownloadManager.Request. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final android.os.Parcelable.Creator<DownloadStatus>Provides a creator field as required by theParcelablecontract.static final intThe download has failed because some possibly transient error occurred but prevents resuming the download.static final intThe download has failed because no external storage device was found.static final intThe download has failed because the requested destination file already exists.static final intThe download has failed because of storage issue which doesn't fit under any other error code.static final intThe download has failed because an error occurred while receiving or processing data at the HTTP level.static final intThe download has failed because there was insufficient storage space.static final intThere are no errors in the download request.static final intThe download has failed because there were too many redirects.static final intThe download has failed because an HTTP code was received that cannot be handled.static final intThe download has failed with an error that doesn't fit under any other error code.static final intThe download exceeds a size limit for downloads over the mobile network and the download manager is waiting for a Wi-Fi connection to proceed.static final intThe download is paused for some other reason.static final intThe download is waiting for network connectivity to proceed.static final intThe download is paused because some network error occurred and the download manager is waiting before retrying the request.static final intStatus ofDownloadManager.Requestthat is being removed before the download is complete.static final intStatus ofDownloadManager.Requestthat has successfully downloaded.static final intStatus ofDownloadManager.Requestthat is being removed after the download is complete.static final intStatus ofDownloadManager.Requestthat is currently being downloaded.static final intStatus ofDownloadManager.Requestthat has failed (and will not be retried).static final intStatus ofDownloadManager.Requestthat has been not queued for download.static final intStatus ofDownloadManager.Requestthat has been paused explicitly.static final intStatus ofDownloadManager.Requestis waiting to start.static final intStatus ofDownloadManager.Requestthat is being queued with theDownloadManagerservice.static final intStatus ofDownloadManager.Requestthat is currently waiting to retry or resume.Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DownloadStatusCreates a newDownloadStatusinstance with error specifying that the DownloadsFile is invalid.intbooleanlongGets the actual total size of the file as number of bytes.longGets the total number of bytes downloaded so far.intgetCode()Gets the status code of the download request.longGets the estimated total size of the file as number of bytes.longGets the maximum size of the file as number of bytes by comparingactualSizeandestimatedSizedoubleCalculates the download progress as percentage value.intGets the reason code of the download request, if any.intConverts the current status code the string resourced identifier that explains the status.intConverts the current status code to a string resource identifier that explains status.longgetTime()Gets the date and time when the status changed as number of milliseconds since January 1, 1970, 00:00:00 GMT.inthashCode()booleanChecks if the status indicates the download is currently marked for deletion.static inttoReasonMessage(int reason) Converts the given reason code to a string resource identifier that explains the reason.static inttoStatusMessage(int code) Converts the given status code to a string resource identifier that explains the status.toString()voidwriteToParcel(android.os.Parcel dest, int flags)
-
Field Details
-
STATUS_PAUSED
public static final int STATUS_PAUSEDStatus ofDownloadManager.Requestthat has been paused explicitly.- See Also:
-
STATUS_DELETING
public static final int STATUS_DELETINGStatus ofDownloadManager.Requestthat is being removed after the download is complete.- See Also:
-
STATUS_CANCELLING
public static final int STATUS_CANCELLINGStatus ofDownloadManager.Requestthat is being removed before the download is complete.- See Also:
-
STATUS_QUEUEING
public static final int STATUS_QUEUEINGStatus ofDownloadManager.Requestthat is being queued with theDownloadManagerservice.- See Also:
-
STATUS_NOT_QUEUED
public static final int STATUS_NOT_QUEUEDStatus ofDownloadManager.Requestthat has been not queued for download.- See Also:
-
STATUS_PENDING
public static final int STATUS_PENDINGStatus ofDownloadManager.Requestis waiting to start.- See Also:
-
STATUS_DOWNLOADING
public static final int STATUS_DOWNLOADINGStatus ofDownloadManager.Requestthat is currently being downloaded.- See Also:
-
STATUS_RETRY
public static final int STATUS_RETRYStatus ofDownloadManager.Requestthat is currently waiting to retry or resume.- See Also:
-
STATUS_FAILED
public static final int STATUS_FAILEDStatus ofDownloadManager.Requestthat has failed (and will not be retried).- See Also:
-
STATUS_COMPLETE
public static final int STATUS_COMPLETEStatus ofDownloadManager.Requestthat has successfully downloaded.- See Also:
-
ERROR_NONE
public static final int ERROR_NONEThere are no errors in the download request.- See Also:
-
PAUSED_WAITING_TO_RETRY
public static final int PAUSED_WAITING_TO_RETRYThe download is paused because some network error occurred and the download manager is waiting before retrying the request.- See Also:
-
PAUSED_WAITING_FOR_NETWORK
public static final int PAUSED_WAITING_FOR_NETWORKThe download is waiting for network connectivity to proceed.- See Also:
-
PAUSED_QUEUED_FOR_WIFI
public static final int PAUSED_QUEUED_FOR_WIFIThe download exceeds a size limit for downloads over the mobile network and the download manager is waiting for a Wi-Fi connection to proceed.- See Also:
-
PAUSED_UNKNOWN
public static final int PAUSED_UNKNOWNThe download is paused for some other reason.- See Also:
-
ERROR_UNKNOWN
public static final int ERROR_UNKNOWNThe download has failed with an error that doesn't fit under any other error code.- See Also:
-
ERROR_FILE_ERROR
public static final int ERROR_FILE_ERRORThe download has failed because of storage issue which doesn't fit under any other error code. Use the more specificERROR_INSUFFICIENT_SPACEandERROR_DEVICE_NOT_FOUNDwhen appropriate.- See Also:
-
ERROR_UNHANDLED_HTTP_CODE
public static final int ERROR_UNHANDLED_HTTP_CODEThe download has failed because an HTTP code was received that cannot be handled.- See Also:
-
ERROR_HTTP_DATA_ERROR
public static final int ERROR_HTTP_DATA_ERRORThe download has failed because an error occurred while receiving or processing data at the HTTP level.- See Also:
-
ERROR_TOO_MANY_REDIRECTS
public static final int ERROR_TOO_MANY_REDIRECTSThe download has failed because there were too many redirects.- See Also:
-
ERROR_INSUFFICIENT_SPACE
public static final int ERROR_INSUFFICIENT_SPACEThe download has failed because there was insufficient storage space. Typically, this is because the SD card is full.- See Also:
-
ERROR_DEVICE_NOT_FOUND
public static final int ERROR_DEVICE_NOT_FOUNDThe download has failed because no external storage device was found. Typically, this is because the SD card is not mounted.- See Also:
-
ERROR_CANNOT_RESUME
public static final int ERROR_CANNOT_RESUMEThe download has failed because some possibly transient error occurred but prevents resuming the download.- See Also:
-
ERROR_FILE_ALREADY_EXISTS
public static final int ERROR_FILE_ALREADY_EXISTSThe download has failed because the requested destination file already exists. Please call delete media and the try again.- See Also:
-
CREATOR
Provides a creator field as required by theParcelablecontract.
-
-
Constructor Details
-
DownloadStatus
public DownloadStatus()
-
-
Method Details
-
createForInvalidDownloadsFile
Creates a newDownloadStatusinstance with error specifying that the DownloadsFile is invalid.- Returns:
- DownloadStatus with code = STATUS_NOT_QUEUED and reason = ERROR_DEVICE_NOT_FOUND.
- See Also:
-
toString
-
equals
-
hashCode
public int hashCode() -
isMarkedForDeletion
public boolean isMarkedForDeletion()Checks if the status indicates the download is currently marked for deletion.- Returns:
- true if the downloads is marked of deletion, otherwise false.
-
getStatusMessage
public int getStatusMessage()Converts the current status code to a string resource identifier that explains status.- Returns:
- the string resource identifier.
-
toStatusMessage
public static int toStatusMessage(int code) Converts the given status code to a string resource identifier that explains the status.- Parameters:
code- the status code.- Returns:
- the matching string resource identifier.
-
getReasonMessage
public int getReasonMessage()Converts the current status code the string resourced identifier that explains the status.- Returns:
- the string resource identifier.
-
toReasonMessage
public static int toReasonMessage(int reason) Converts the given reason code to a string resource identifier that explains the reason.- Parameters:
reason- the reason code.- Returns:
- the matching string resource identifier.
-
getTime
public long getTime()Gets the date and time when the status changed as number of milliseconds since January 1, 1970, 00:00:00 GMT.- Returns:
- epoch time as milliseconds.
-
getCode
public int getCode()Gets the status code of the download request.- Returns:
- 0 if the download request is not found, otherwise the download status code.
-
getReason
public int getReason()Gets the reason code of the download request, if any.- Returns:
- 0 if the download request is not paused or failed, otherwise the reason code.
-
getBytesDownloaded
public long getBytesDownloaded()Gets the total number of bytes downloaded so far.- Returns:
- 0 if the download request is not found, otherwise the total number of bytes downloaded so far.
-
getActualSize
public long getActualSize()Gets the actual total size of the file as number of bytes.- Returns:
- 0 if the download request is not found, otherwise the actual total size of the file as number of bytes.
-
getEstimatedSize
public long getEstimatedSize()Gets the estimated total size of the file as number of bytes.- Returns:
- 0 if the download request is not found, otherwise the estimated total size of the file as number of bytes.
-
getMaxSize
public long getMaxSize()Gets the maximum size of the file as number of bytes by comparingactualSizeandestimatedSize- Returns:
- 0 if the download request is not found, otherwise the maximum size of the file as number of bytes.
-
getProgress
public double getProgress()Calculates the download progress as percentage value.- Returns:
Double.NaNif theactualSizeis zero, otherwise a value between 0 and 100.
-
describeContents
public int describeContents()- Specified by:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags) - Specified by:
writeToParcelin interfaceandroid.os.Parcelable
-