mirror of https://github.com/M66B/FairEmail.git
Single shot tasks
This commit is contained in:
parent
aef7175dd0
commit
b506a2b579
|
@ -6138,7 +6138,7 @@ public class FragmentMessages extends FragmentBase
|
|||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.setExecutor(executor).execute(this, args, "quickactions");
|
||||
}.setExecutor(executor).setId("messages:" + FragmentMessages.this.hashCode()).execute(this, args, "quickactions");
|
||||
} else {
|
||||
fabMore.hide();
|
||||
tvSelectedCount.setVisibility(View.GONE);
|
||||
|
|
|
@ -54,6 +54,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|||
private boolean count = true;
|
||||
private boolean keepawake = false;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private long started;
|
||||
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";
|
||||
|
||||
public SimpleTask<T> setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleTask<T> setLog(boolean log) {
|
||||
this.log = log;
|
||||
if (!log)
|
||||
|
@ -143,6 +149,10 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|||
|
||||
// prevent garbage collection
|
||||
synchronized (tasks) {
|
||||
if (id != null)
|
||||
for (SimpleTask task : tasks)
|
||||
if (id.equals(task.id))
|
||||
task.cancel(context);
|
||||
tasks.add(this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue