Fix a bug where cards overlap when rotating the screen

Check if a certain fragment has been added before. If it's added, then
just show it instead of re-adding it again.

Bug: 118344247
Test: visual
Change-Id: I039a3a7372e163c6bcda386d2aea99e6f8c8e9b1
This commit is contained in:
Emily Chuang
2018-10-24 19:42:17 +08:00
parent 5cec560cf3
commit b97bfb0885

View File

@@ -65,7 +65,13 @@ public class SettingsHomepageActivity extends SettingsBaseActivity {
private void showFragment(Fragment fragment, int id, String tag) {
final FragmentManager fragmentManager = getSupportFragmentManager();
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(id, fragment, tag);
final Fragment showFragment = fragmentManager.findFragmentById(id);
if (showFragment == null) {
fragmentTransaction.add(id, fragment, tag);
} else {
fragmentTransaction.show(showFragment);
}
fragmentTransaction.commit();
}
}