From d2d7e9a7264f042406f824f37765a29da67e4cbf Mon Sep 17 00:00:00 2001 From: PeratX <1215714524@qq.com> Date: Tue, 23 May 2017 20:25:39 +0800 Subject: [PATCH] Fixed GlobalConfigFragment crash --- .../java/org/itxtech/daedalus/activity/MainActivity.java | 1 + .../org/itxtech/daedalus/fragment/SettingsFragment.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java b/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java index eafb137..2b55164 100644 --- a/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java +++ b/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java @@ -127,6 +127,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On Log.d(TAG, "onDestroy"); instance = null; + currentFragment = null; } @Override diff --git a/app/src/main/java/org/itxtech/daedalus/fragment/SettingsFragment.java b/app/src/main/java/org/itxtech/daedalus/fragment/SettingsFragment.java index 13d0aa1..41e1620 100644 --- a/app/src/main/java/org/itxtech/daedalus/fragment/SettingsFragment.java +++ b/app/src/main/java/org/itxtech/daedalus/fragment/SettingsFragment.java @@ -1,6 +1,7 @@ package org.itxtech.daedalus.fragment; import android.app.FragmentManager; +import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -27,7 +28,12 @@ public class SettingsFragment extends ToolbarFragment { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - FragmentManager fm = getFragmentManager(); + FragmentManager fm; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + fm = getChildFragmentManager(); + } else { + fm = getFragmentManager(); + } fm.beginTransaction().replace(R.id.settings_content, new GlobalConfigFragment()).commit(); }