From fd1013b6ada74e0e31dbda7ae3dfc13d2a5a6b85 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 29 May 2022 13:57:54 +0200 Subject: [PATCH] Cancel orphan toasts --- app/src/main/java/eu/faircode/email/ActivityEML.java | 5 ++++- app/src/main/java/eu/faircode/email/ActivitySetup.java | 5 ++++- app/src/main/java/eu/faircode/email/AdapterRule.java | 5 ++++- .../main/java/eu/faircode/email/FragmentCompose.java | 10 ++++++++-- .../main/java/eu/faircode/email/FragmentContacts.java | 10 ++++++++-- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityEML.java b/app/src/main/java/eu/faircode/email/ActivityEML.java index f5ebf6beeb..426242dcd3 100644 --- a/app/src/main/java/eu/faircode/email/ActivityEML.java +++ b/app/src/main/java/eu/faircode/email/ActivityEML.java @@ -679,7 +679,10 @@ public class ActivityEML extends ActivityBase { @Override protected void onDestroyed(Bundle args) { - toast = null; + if (toast != null) { + toast.cancel(); + toast = null; + } } @Override diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index 6e73f88654..27bce63d85 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -791,7 +791,10 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac @Override protected void onDestroyed(Bundle args) { - toast = null; + if (toast != null) { + toast.cancel(); + toast = null; + } } @Override diff --git a/app/src/main/java/eu/faircode/email/AdapterRule.java b/app/src/main/java/eu/faircode/email/AdapterRule.java index 50f00fe6e0..29dfc4613c 100644 --- a/app/src/main/java/eu/faircode/email/AdapterRule.java +++ b/app/src/main/java/eu/faircode/email/AdapterRule.java @@ -413,7 +413,10 @@ public class AdapterRule extends RecyclerView.Adapter { @Override protected void onDestroyed(Bundle args) { - toast = null; + if (toast != null) { + toast.cancel(); + toast = null; + } } @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index a88e83d2a1..1136bd476e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -2397,7 +2397,10 @@ public class FragmentCompose extends FragmentBase { @Override protected void onDestroyed(Bundle args) { - toast = null; + if (toast != null) { + toast.cancel(); + toast = null; + } } @Override @@ -2474,7 +2477,10 @@ public class FragmentCompose extends FragmentBase { @Override protected void onDestroyed(Bundle args) { - toast = null; + if (toast != null) { + toast.cancel(); + toast = null; + } } @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentContacts.java b/app/src/main/java/eu/faircode/email/FragmentContacts.java index bb81286061..1b54763940 100644 --- a/app/src/main/java/eu/faircode/email/FragmentContacts.java +++ b/app/src/main/java/eu/faircode/email/FragmentContacts.java @@ -498,7 +498,10 @@ public class FragmentContacts extends FragmentBase { @Override protected void onDestroyed(Bundle args) { - toast = null; + if (toast != null) { + toast.cancel(); + toast = null; + } } @Override @@ -597,7 +600,10 @@ public class FragmentContacts extends FragmentBase { @Override protected void onDestroyed(Bundle args) { - toast = null; + if (toast != null) { + toast.cancel(); + toast = null; + } } @Override