From f684c1edc966d0246c3c8cdeb5b0ca86295ef501 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 25 Jul 2018 03:07:16 +0200 Subject: MainActivity: attempt to fix commit state exceptions This is an attempt to fix: java.lang.IllegalStateException: at android.support.v4.app.FragmentManagerImpl.checkStateLoss (FragmentManager.java:2053) at android.support.v4.app.FragmentManagerImpl.enqueueAction (FragmentManager.java:2079) at android.support.v4.app.BackStackRecord.commitInternal (BackStackRecord.java:678) at android.support.v4.app.BackStackRecord.commit (BackStackRecord.java:632) at com.wireguard.android.activity.MainActivity.moveToState (MainActivity.java:58) at com.wireguard.android.activity.MainActivity.onSelectedTunnelChanged (MainActivity.java:157) at com.wireguard.android.activity.BaseActivity.setSelectedTunnel (BaseActivity.java:75) at com.wireguard.android.fragment.BaseFragment.setSelectedTunnel (BaseFragment.java:82) at com.wireguard.android.fragment.TunnelListFragment.lambda$null$4$TunnelListFragment (TunnelListFragment.java:307) at com.wireguard.android.fragment.TunnelListFragment$$Lambda$4.onClick (Unknown Source:6) at android.view.View.performClick (View.java:6274) at android.view.View$PerformClick.run (View.java:24729) at android.os.Handler.handleCallback (Handler.java:789) at android.os.Handler.dispatchMessage (Handler.java:98) at android.os.Looper.loop (Looper.java:169) at android.app.ActivityThread.main (ActivityThread.java:6595) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767) But this is probably the wrong way to fix it and instead moveToState needs to be reimagined. --- app/src/main/java/com/wireguard/android/activity/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/java/com/wireguard/android/activity/MainActivity.java b/app/src/main/java/com/wireguard/android/activity/MainActivity.java index 5a8134f3..b3c21133 100644 --- a/app/src/main/java/com/wireguard/android/activity/MainActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/MainActivity.java @@ -55,7 +55,7 @@ public class MainActivity extends BaseActivity { .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); if (state.layer > 0) transaction.addToBackStack(null); - transaction.commit(); + transaction.commitAllowingStateLoss(); /* TODO: switch back to .commit() when this function is rewritten. */ } else if (nextState.layer == state.layer - 1) { if (fragmentManager.getBackStackEntryCount() == 0) return false; -- cgit v1.2.3