Added sail-safe

pull/212/head
M66B 2 years ago
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…
Cancel
Save