Class Download
- java.lang.Object
-
- com.google.android.exoplayer2.offline.Download
-
public final class Download extends Object
Represents state of a download.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Download.FailureReason
Failure reasons.static interface
Download.State
Download states.
-
Field Summary
Fields Modifier and Type Field Description long
contentLength
The total size of the content in bytes, orC.LENGTH_UNSET
if unknown.static int
FAILURE_REASON_NONE
The download isn't failed.static int
FAILURE_REASON_UNKNOWN
The download is failed because of unknown reason.@com.google.android.exoplayer2.offline.Download.FailureReason int
failureReason
DownloadRequest
request
The download request.long
startTimeMs
The first time when download entry is created.@com.google.android.exoplayer2.offline.Download.State int
state
The state of the download.static int
STATE_COMPLETED
The download completed.static int
STATE_DOWNLOADING
The download is currently started.static int
STATE_FAILED
The download failed.static int
STATE_QUEUED
The download is waiting to be started.static int
STATE_REMOVING
The download is being removed.static int
STATE_RESTARTING
The download will restart after all downloaded data is removed.static int
STATE_STOPPED
The download is stopped for a specifiedstopReason
.static int
STOP_REASON_NONE
The download isn't stopped.int
stopReason
The reason the download is stopped, orSTOP_REASON_NONE
.long
updateTimeMs
The last update time.
-
Constructor Summary
Constructors Constructor Description Download(DownloadRequest request, @com.google.android.exoplayer2.offline.Download.State int state, long startTimeMs, long updateTimeMs, long contentLength, int stopReason, @com.google.android.exoplayer2.offline.Download.FailureReason int failureReason)
Download(DownloadRequest request, @com.google.android.exoplayer2.offline.Download.State int state, long startTimeMs, long updateTimeMs, long contentLength, int stopReason, @com.google.android.exoplayer2.offline.Download.FailureReason int failureReason, DownloadProgress progress)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getBytesDownloaded()
Returns the total number of downloaded bytes.float
getPercentDownloaded()
Returns the estimated download percentage, orC.PERCENTAGE_UNSET
if no estimate is available.boolean
isTerminalState()
Returns whether the download is completed or failed.
-
-
-
Field Detail
-
STATE_QUEUED
public static final int STATE_QUEUED
The download is waiting to be started. A download may be queued because theDownloadManager
- Is
DownloadManager#getDownloadsPaused() paused
- Has
DownloadManager#getRequirements() Requirements
that are not met - Has already started
DownloadManager#getMaxParallelDownloads() maxParallelDownloads
- See Also:
- Constant Field Values
- Is
-
STATE_STOPPED
public static final int STATE_STOPPED
The download is stopped for a specifiedstopReason
.- See Also:
- Constant Field Values
-
STATE_DOWNLOADING
public static final int STATE_DOWNLOADING
The download is currently started.- See Also:
- Constant Field Values
-
STATE_COMPLETED
public static final int STATE_COMPLETED
The download completed.- See Also:
- Constant Field Values
-
STATE_FAILED
public static final int STATE_FAILED
The download failed.- See Also:
- Constant Field Values
-
STATE_REMOVING
public static final int STATE_REMOVING
The download is being removed.- See Also:
- Constant Field Values
-
STATE_RESTARTING
public static final int STATE_RESTARTING
The download will restart after all downloaded data is removed.- See Also:
- Constant Field Values
-
FAILURE_REASON_NONE
public static final int FAILURE_REASON_NONE
The download isn't failed.- See Also:
- Constant Field Values
-
FAILURE_REASON_UNKNOWN
public static final int FAILURE_REASON_UNKNOWN
The download is failed because of unknown reason.- See Also:
- Constant Field Values
-
STOP_REASON_NONE
public static final int STOP_REASON_NONE
The download isn't stopped.- See Also:
- Constant Field Values
-
request
public final DownloadRequest request
The download request.
-
state
@State public final @com.google.android.exoplayer2.offline.Download.State int state
The state of the download.
-
startTimeMs
public final long startTimeMs
The first time when download entry is created.
-
updateTimeMs
public final long updateTimeMs
The last update time.
-
contentLength
public final long contentLength
The total size of the content in bytes, orC.LENGTH_UNSET
if unknown.
-
stopReason
public final int stopReason
The reason the download is stopped, orSTOP_REASON_NONE
.
-
failureReason
@FailureReason public final @com.google.android.exoplayer2.offline.Download.FailureReason int failureReason
-
-
Constructor Detail
-
Download
public Download(DownloadRequest request, @State @com.google.android.exoplayer2.offline.Download.State int state, long startTimeMs, long updateTimeMs, long contentLength, int stopReason, @FailureReason @com.google.android.exoplayer2.offline.Download.FailureReason int failureReason)
-
Download
public Download(DownloadRequest request, @State @com.google.android.exoplayer2.offline.Download.State int state, long startTimeMs, long updateTimeMs, long contentLength, int stopReason, @FailureReason @com.google.android.exoplayer2.offline.Download.FailureReason int failureReason, DownloadProgress progress)
-
-
Method Detail
-
isTerminalState
public boolean isTerminalState()
Returns whether the download is completed or failed. These are terminal states.
-
getBytesDownloaded
public long getBytesDownloaded()
Returns the total number of downloaded bytes.
-
getPercentDownloaded
public float getPercentDownloaded()
Returns the estimated download percentage, orC.PERCENTAGE_UNSET
if no estimate is available.
-
-