mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add DownloadNotificationHelper
Helper class to create notifications for downloads using DownloadManager. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183225948
This commit is contained in:
parent
b3da82dc1c
commit
e1dbaf26c2
1 changed files with 18 additions and 11 deletions
|
|
@ -472,6 +472,16 @@ public final class DownloadManager {
|
||||||
/** The task failed. */
|
/** The task failed. */
|
||||||
public static final int STATE_ERROR = 6;
|
public static final int STATE_ERROR = 6;
|
||||||
|
|
||||||
|
/** Returns whether the task is running. */
|
||||||
|
public static boolean isRunning(int state) {
|
||||||
|
return state == STATE_STARTED || state == STATE_STOPPING || state == STATE_CANCELING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns whether the task is finished. */
|
||||||
|
public static boolean isFinished(int state) {
|
||||||
|
return state == STATE_ERROR || state == STATE_ENDED || state == STATE_CANCELED;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the state string for the given state value. */
|
/** Returns the state string for the given state value. */
|
||||||
public static String getStateString(@State int state) {
|
public static String getStateString(@State int state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
|
@ -530,7 +540,12 @@ public final class DownloadManager {
|
||||||
|
|
||||||
/** Returns whether the task is finished. */
|
/** Returns whether the task is finished. */
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return state == STATE_ERROR || state == STATE_ENDED || state == STATE_CANCELED;
|
return isFinished(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns whether the task is running. */
|
||||||
|
public boolean isRunning() {
|
||||||
|
return isRunning(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -559,11 +574,6 @@ public final class DownloadManager {
|
||||||
id, downloadAction, currentState, getDownloadPercentage(), getDownloadedBytes(), error);
|
id, downloadAction, currentState, getDownloadPercentage(), getDownloadedBytes(), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the {@link DownloadAction}. */
|
|
||||||
public DownloadAction getDownloadAction() {
|
|
||||||
return downloadAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the state of the task. */
|
/** Returns the state of the task. */
|
||||||
public @State int getState() {
|
public @State int getState() {
|
||||||
return currentState;
|
return currentState;
|
||||||
|
|
@ -571,15 +581,12 @@ public final class DownloadManager {
|
||||||
|
|
||||||
/** Returns whether the task is finished. */
|
/** Returns whether the task is finished. */
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
return currentState == STATE_ERROR || currentState == STATE_ENDED
|
return DownloadState.isFinished(currentState);
|
||||||
|| currentState == STATE_CANCELED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether the task is running. */
|
/** Returns whether the task is running. */
|
||||||
public boolean isRunning() {
|
public boolean isRunning() {
|
||||||
return currentState == STATE_STARTED
|
return DownloadState.isRunning(currentState);
|
||||||
|| currentState == STATE_STOPPING
|
|
||||||
|| currentState == STATE_CANCELING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue