mirror of https://github.com/M66B/FairEmail.git
Added sail-safe
This commit is contained in:
parent
8a166a5000
commit
c2c4683d12
|
@ -359,11 +359,16 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
|||
}
|
||||
|
||||
void cancel(Context context) {
|
||||
ExecutorService executor = getExecutor(context);
|
||||
if (executor instanceof ThreadPoolExecutor && future instanceof Runnable) {
|
||||
boolean removed = ((ThreadPoolExecutor) executor).remove((Runnable) future);
|
||||
Log.i("Remove task=" + name + " removed=" + removed);
|
||||
try {
|
||||
ExecutorService executor = getExecutor(context);
|
||||
if (executor instanceof ThreadPoolExecutor && future instanceof Runnable) {
|
||||
boolean removed = ((ThreadPoolExecutor) executor).remove((Runnable) future);
|
||||
Log.i("Remove task=" + name + " removed=" + removed);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
|
||||
if (future != null && future.cancel(false)) {
|
||||
Log.i("Cancelled task=" + name);
|
||||
cleanup(context);
|
||||
|
|
Loading…
Reference in New Issue