Prevent crash

This commit is contained in:
M66B 2022-04-03 11:43:53 +02:00
parent 55ad97ad4d
commit bfd6b2ac0d
1 changed files with 16 additions and 2 deletions

View File

@ -196,7 +196,11 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
getArguments().putLongArray("ids", ids); getArguments().putLongArray("ids", ids);
enabled = true; enabled = true;
Button ok = getPositiveButton(); Button ok = getPositiveButton();
if (ok == null)
return;
ok.setEnabled(enabled); ok.setEnabled(enabled);
boolean eml_auto_confirm = prefs.getBoolean("eml_auto_confirm", false); boolean eml_auto_confirm = prefs.getBoolean("eml_auto_confirm", false);
@ -204,7 +208,15 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
ok.postDelayed(new Runnable() { ok.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
getPositiveButton().performClick(); try {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
return;
Button ok = getPositiveButton();
if (ok != null)
ok.performClick();
} catch (Throwable ex) {
Log.e(ex);
}
} }
}, AUTO_CONFIRM_DELAY); }, AUTO_CONFIRM_DELAY);
} }
@ -239,7 +251,9 @@ public class FragmentDialogForwardRaw extends FragmentDialogBase {
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
getPositiveButton().setEnabled(enabled); Button ok = getPositiveButton();
if (ok != null)
ok.setEnabled(enabled);
} }
private Button getPositiveButton() { private Button getPositiveButton() {