|
|
@ -54,6 +54,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|
|
|
private boolean count = true;
|
|
|
|
private boolean count = true;
|
|
|
|
private boolean keepawake = false;
|
|
|
|
private boolean keepawake = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String id;
|
|
|
|
private String name;
|
|
|
|
private String name;
|
|
|
|
private long started;
|
|
|
|
private long started;
|
|
|
|
private boolean destroyed;
|
|
|
|
private boolean destroyed;
|
|
|
@ -74,6 +75,11 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|
|
|
|
|
|
|
|
|
|
|
static final String ACTION_TASK_COUNT = BuildConfig.APPLICATION_ID + ".ACTION_TASK_COUNT";
|
|
|
|
static final String ACTION_TASK_COUNT = BuildConfig.APPLICATION_ID + ".ACTION_TASK_COUNT";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SimpleTask<T> setId(String id) {
|
|
|
|
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SimpleTask<T> setLog(boolean log) {
|
|
|
|
public SimpleTask<T> setLog(boolean log) {
|
|
|
|
this.log = log;
|
|
|
|
this.log = log;
|
|
|
|
if (!log)
|
|
|
|
if (!log)
|
|
|
@ -143,6 +149,10 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|
|
|
|
|
|
|
|
|
|
|
// prevent garbage collection
|
|
|
|
// prevent garbage collection
|
|
|
|
synchronized (tasks) {
|
|
|
|
synchronized (tasks) {
|
|
|
|
|
|
|
|
if (id != null)
|
|
|
|
|
|
|
|
for (SimpleTask task : tasks)
|
|
|
|
|
|
|
|
if (id.equals(task.id))
|
|
|
|
|
|
|
|
task.cancel(context);
|
|
|
|
tasks.add(this);
|
|
|
|
tasks.add(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|