diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 61a983283d..e45fd8e85c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -420,6 +420,8 @@ public class FragmentAccount extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, btnAdvanced.getTop()); } }); @@ -781,6 +783,8 @@ public class FragmentAccount extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, cbIdentity.getBottom()); } }); @@ -1371,6 +1375,8 @@ public class FragmentAccount extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; if (provider != null && provider.documentation != null) scroll.smoothScrollTo(0, tvInstructions.getBottom()); else @@ -1695,6 +1701,8 @@ public class FragmentAccount extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, (save ? btnSave : btnCheck).getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 6980181dff..29da2efe1e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -579,6 +579,8 @@ public class FragmentCompose extends FragmentBase { getMainHandler().postDelayed(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; if (styling != selection) { styling = selection; media_bar.getMenu().clear(); @@ -1688,6 +1690,8 @@ public class FragmentCompose extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; if (grpAddresses.getVisibility() == View.GONE) etSubject.requestFocus(); else @@ -6255,6 +6259,9 @@ public class FragmentCompose extends FragmentBase { @Override public void run() { try { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; + if (target instanceof EditText) { EditText et = (EditText) target; int len = et.length(); diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java index 1f78855083..a11fbdcca0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogOpenLink.java @@ -60,6 +60,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.constraintlayout.widget.Group; import androidx.core.net.MailTo; import androidx.core.util.PatternsCompat; +import androidx.lifecycle.Lifecycle; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; @@ -344,6 +345,8 @@ public class FragmentDialogOpenLink extends FragmentDialogBase { ApplicationEx.getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; dview.scrollTo(0, tvOwner.getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentFolder.java b/app/src/main/java/eu/faircode/email/FragmentFolder.java index 79f7eac81e..cd80bdb323 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolder.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolder.java @@ -382,6 +382,8 @@ public class FragmentFolder extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, btnSave.getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentGmail.java b/app/src/main/java/eu/faircode/email/FragmentGmail.java index ae55b8b00b..be117690af 100644 --- a/app/src/main/java/eu/faircode/email/FragmentGmail.java +++ b/app/src/main/java/eu/faircode/email/FragmentGmail.java @@ -55,6 +55,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; +import androidx.lifecycle.Lifecycle; import java.util.Date; import java.util.HashMap; @@ -270,6 +271,8 @@ public class FragmentGmail extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; etName.requestFocus(); } }); @@ -335,6 +338,8 @@ public class FragmentGmail extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, tvError.getBottom()); } }); @@ -565,6 +570,8 @@ public class FragmentGmail extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, tvError.getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 4ee78aec14..3d515b7b91 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -371,6 +371,8 @@ public class FragmentIdentity extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, btnAdvanced.getTop()); } }); @@ -1071,6 +1073,8 @@ public class FragmentIdentity extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; if (provider != null && provider.documentation != null) scroll.smoothScrollTo(0, tvInstructions.getBottom()); else @@ -1361,6 +1365,8 @@ public class FragmentIdentity extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, btnSave.getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentOAuth.java b/app/src/main/java/eu/faircode/email/FragmentOAuth.java index 334e553864..2d2a7a9c14 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOAuth.java +++ b/app/src/main/java/eu/faircode/email/FragmentOAuth.java @@ -50,6 +50,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; +import androidx.lifecycle.Lifecycle; import androidx.preference.PreferenceManager; import net.openid.appauth.AppAuthConfiguration; @@ -929,6 +930,8 @@ public class FragmentOAuth extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, tvError.getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java index 1ab6c545a9..d26fdce039 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java @@ -447,13 +447,13 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre getMainHandler().post(new Runnable() { @Override public void run() { - if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) { - tvNetworkMetered.setText(networkState.isUnmetered() ? R.string.title_legend_unmetered : R.string.title_legend_metered); - tvNetworkInfo.setText(sb.toString()); - tvNetworkMetered.setVisibility(networkState.isConnected() ? View.VISIBLE : View.GONE); - tvNetworkRoaming.setVisibility(networkState.isRoaming() ? View.VISIBLE : View.GONE); - cardDebug.setVisibility(sb.length() == 0 ? View.GONE : View.VISIBLE); - } + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; + tvNetworkMetered.setText(networkState.isUnmetered() ? R.string.title_legend_unmetered : R.string.title_legend_metered); + tvNetworkInfo.setText(sb.toString()); + tvNetworkMetered.setVisibility(networkState.isConnected() ? View.VISIBLE : View.GONE); + tvNetworkRoaming.setVisibility(networkState.isRoaming() ? View.VISIBLE : View.GONE); + cardDebug.setVisibility(sb.length() == 0 ? View.GONE : View.VISIBLE); } }); } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java index 27a6ce9e32..118230c03c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java @@ -529,6 +529,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer ApplicationEx.getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; etPin.requestFocus(); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java index 47565233f5..590f9193d5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPop.java +++ b/app/src/main/java/eu/faircode/email/FragmentPop.java @@ -677,6 +677,8 @@ public class FragmentPop extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, tvError.getBottom()); } }); @@ -854,6 +856,8 @@ public class FragmentPop extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, btnSave.getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java b/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java index 8de71e48c6..022eda5625 100644 --- a/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentQuickSetup.java @@ -47,6 +47,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.Lifecycle; import com.google.android.material.textfield.TextInputLayout; @@ -546,6 +547,8 @@ public class FragmentQuickSetup extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, btnSupport.getBottom()); } }); @@ -575,6 +578,8 @@ public class FragmentQuickSetup extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, btnSupport.getBottom()); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentRule.java b/app/src/main/java/eu/faircode/email/FragmentRule.java index f7dee87ccd..f77b97f1eb 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRule.java +++ b/app/src/main/java/eu/faircode/email/FragmentRule.java @@ -56,6 +56,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.Group; import androidx.fragment.app.DialogFragment; +import androidx.lifecycle.Lifecycle; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -483,6 +484,8 @@ public class FragmentRule extends FragmentBase { getMainHandler().post(new Runnable() { @Override public void run() { + if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) + return; scroll.smoothScrollTo(0, content.getBottom()); } });