Android: Don't save fragment state
We have custom constructors and state which break this.
This commit is contained in:
parent
fd7d77bc70
commit
cc48b6cc7b
|
@ -16,6 +16,8 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentFactory;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
@ -48,6 +50,12 @@ public class ControllerMappingActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.remove("android:support:fragments");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
|
|
|
@ -50,10 +50,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
private boolean mHasExternalStoragePermissions = false;
|
||||
private boolean mIsShowingGameGrid = false;
|
||||
|
||||
public MainActivity() {
|
||||
getSupportFragmentManager().setFragmentFactory(createFragmentFactory());
|
||||
}
|
||||
|
||||
private static String getTitleString() {
|
||||
String scmVersion = AndroidHostInterface.getScmVersion();
|
||||
final int gitHashPos = scmVersion.indexOf("-g");
|
||||
|
@ -113,21 +109,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
mIsShowingGameGrid = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("Main/GameGridView", false);
|
||||
}
|
||||
|
||||
private FragmentFactory createFragmentFactory() {
|
||||
return new FragmentFactory() {
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment instantiate(@NonNull ClassLoader classLoader, @NonNull String className) {
|
||||
if (className == GameListFragment.class.getName())
|
||||
return new GameListFragment(MainActivity.this);
|
||||
else if (className == GameGridFragment.class.getName())
|
||||
return new GameGridFragment(MainActivity.this);
|
||||
|
||||
return super.instantiate(classLoader, className);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void switchGameListView() {
|
||||
mIsShowingGameGrid = !mIsShowingGameGrid;
|
||||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
|
@ -181,6 +162,12 @@ public class MainActivity extends AppCompatActivity {
|
|||
completeStartup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.remove("android:support:fragments");
|
||||
}
|
||||
|
||||
private void completeStartup() {
|
||||
if (!AndroidHostInterface.hasInstance() && !AndroidHostInterface.createInstance(this)) {
|
||||
Log.i("MainActivity", "Failed to create host interface");
|
||||
|
|
|
@ -34,6 +34,12 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.remove("android:support:fragments");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
|
|
Loading…
Reference in New Issue