Commit 771aa080 by eguven Committed by Andrew Lewis

Add totalBytes to TaskState

PiperOrigin-RevId: 224506700
parent 17e8c554
...@@ -523,6 +523,8 @@ public final class DownloadManager { ...@@ -523,6 +523,8 @@ public final class DownloadManager {
public final float downloadPercentage; public final float downloadPercentage;
/** The total number of downloaded bytes. */ /** The total number of downloaded bytes. */
public final long downloadedBytes; public final long downloadedBytes;
/** The total size of the media, or {@link C#LENGTH_UNSET} if unknown. */
public final long totalBytes;
/** If {@link #state} is {@link #STATE_FAILED} then this is the cause, otherwise null. */ /** If {@link #state} is {@link #STATE_FAILED} then this is the cause, otherwise null. */
@Nullable public final Throwable error; @Nullable public final Throwable error;
...@@ -533,12 +535,14 @@ public final class DownloadManager { ...@@ -533,12 +535,14 @@ public final class DownloadManager {
@State int state, @State int state,
float downloadPercentage, float downloadPercentage,
long downloadedBytes, long downloadedBytes,
long totalBytes,
@Nullable Throwable error) { @Nullable Throwable error) {
this.taskId = taskId; this.taskId = taskId;
this.action = action; this.action = action;
this.state = state; this.state = state;
this.downloadPercentage = downloadPercentage; this.downloadPercentage = downloadPercentage;
this.downloadedBytes = downloadedBytes; this.downloadedBytes = downloadedBytes;
this.totalBytes = totalBytes;
this.error = error; this.error = error;
} }
...@@ -587,11 +591,14 @@ public final class DownloadManager { ...@@ -587,11 +591,14 @@ public final class DownloadManager {
public TaskState getTaskState() { public TaskState getTaskState() {
float downloadPercentage = C.PERCENTAGE_UNSET; float downloadPercentage = C.PERCENTAGE_UNSET;
long downloadedBytes = 0; long downloadedBytes = 0;
long totalBytes = C.LENGTH_UNSET;
if (downloader != null) { if (downloader != null) {
downloadPercentage = downloader.getDownloadPercentage(); downloadPercentage = downloader.getDownloadPercentage();
downloadedBytes = downloader.getDownloadedBytes(); downloadedBytes = downloader.getDownloadedBytes();
totalBytes = downloader.getTotalBytes();
} }
return new TaskState(id, action, state, downloadPercentage, downloadedBytes, error); return new TaskState(
id, action, state, downloadPercentage, downloadedBytes, totalBytes, error);
} }
/** Returns whether the task is finished. */ /** Returns whether the task is finished. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment