mirror of https://github.com/M66B/FairEmail.git
Some tasks should not be interrupted
This commit is contained in:
parent
635115730a
commit
a63b237bda
|
@ -725,7 +725,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
||||||
ex instanceof SecurityException);
|
ex instanceof SecurityException);
|
||||||
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
|
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
|
||||||
}
|
}
|
||||||
}.execute(this, args, "setup:export");
|
}.setInterruptable(false).execute(this, args, "setup:export");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleImport(Intent data, String password) {
|
private void handleImport(Intent data, String password) {
|
||||||
|
@ -1115,7 +1115,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
||||||
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
|
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.execute(this, args, "setup:import");
|
}.setInterruptable(false).execute(this, args, "setup:import");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleImportCertificate(Intent data) {
|
private void handleImportCertificate(Intent data) {
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ public class FragmentFolders extends FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}.execute(this, args, "folder:export");
|
}.setInterruptable(false).execute(this, args, "folder:export");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FragmentDialogApply extends FragmentDialogBase {
|
public static class FragmentDialogApply extends FragmentDialogBase {
|
||||||
|
|
|
@ -51,6 +51,7 @@ import java.util.concurrent.Future;
|
||||||
public abstract class SimpleTask<T> implements LifecycleObserver {
|
public abstract class SimpleTask<T> implements LifecycleObserver {
|
||||||
private boolean log = true;
|
private boolean log = true;
|
||||||
private boolean count = true;
|
private boolean count = true;
|
||||||
|
private boolean interruptable = true;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private long started;
|
private long started;
|
||||||
|
@ -82,6 +83,11 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleTask<T> setInterruptable(boolean interruptable) {
|
||||||
|
this.interruptable = interruptable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public SimpleTask<T> setExecutor(ExecutorService executor) {
|
public SimpleTask<T> setExecutor(ExecutorService executor) {
|
||||||
this.localExecutor = executor;
|
this.localExecutor = executor;
|
||||||
return this;
|
return this;
|
||||||
|
@ -284,7 +290,8 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
|
||||||
long elapsed = now - task.started;
|
long elapsed = now - task.started;
|
||||||
if (elapsed > CANCEL_AFTER && !task.interrupted) {
|
if (elapsed > CANCEL_AFTER && !task.interrupted) {
|
||||||
task.interrupted = true;
|
task.interrupted = true;
|
||||||
if (task.future != null && !task.future.isDone()) {
|
if (task.interruptable &&
|
||||||
|
task.future != null && !task.future.isDone()) {
|
||||||
Log.e("Interrupting task " + task +
|
Log.e("Interrupting task " + task +
|
||||||
" tasks=" + getCountLocked() + "/" + tasks.size());
|
" tasks=" + getCountLocked() + "/" + tasks.size());
|
||||||
task.future.cancel(true);
|
task.future.cancel(true);
|
||||||
|
|
Loading…
Reference in New Issue