mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-29 20:26:34 +02:00
Kill media tasks
This commit is contained in:
@@ -54,6 +54,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
||||
private boolean log = true;
|
||||
private boolean count = true;
|
||||
private boolean keepawake = false;
|
||||
private boolean kill = false;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@@ -104,6 +105,12 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public SimpleTask<T> setKill(boolean kill) {
|
||||
this.kill = kill;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public SimpleTask<T> setExecutor(ExecutorService executor) {
|
||||
this.localExecutor = executor;
|
||||
@@ -447,6 +454,13 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
||||
}
|
||||
|
||||
protected void onDestroyed(Bundle args) {
|
||||
if (this.kill && future != null)
|
||||
try {
|
||||
Log.i("Killing task=" + name);
|
||||
future.cancel(true);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user