Fix fragment transactions on host wizard: previous fragments weren't being properly removed with the call to replace() on the FragmentTransaction, because the container used was the global one. Somehow this stopped working with recent versions

This commit is contained in:
Synced Synapse 2015-07-30 23:24:44 +01:00
parent d8750cc6db
commit c9e643fc2c
3 changed files with 17 additions and 4 deletions

View File

@ -38,16 +38,20 @@ public class AddHostActivity extends BaseActivity
HostFragmentManualConfiguration.HostManualConfigurationListener,
AddHostFragmentFinish.AddHostFinishListener {
private Fragment previousFragment = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_host_wizard);
// Only load first fragment if we're starting the activity
if (savedInstanceState == null) {
AddHostFragmentWelcome firstStep = new AddHostFragmentWelcome();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, firstStep)
.add(R.id.fragment_container, firstStep)
.commit();
}
@ -156,7 +160,7 @@ public class AddHostActivity extends BaseActivity
private void switchToFragment(Fragment fragment) {
getSupportFragmentManager()
.beginTransaction()
.replace(android.R.id.content, fragment)
.replace(R.id.fragment_container, fragment)
.commit();
}
}

View File

@ -39,6 +39,7 @@ public class EditHostActivity extends BaseActivity implements
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_host_wizard);
// Only load first fragment if we're starting the activity
if (savedInstanceState == null) {
@ -87,14 +88,14 @@ public class EditHostActivity extends BaseActivity implements
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, editFragment)
.add(R.id.fragment_container, editFragment)
.commit();
}
setupActionBar();
// // Setup system bars and content padding
// setupSystemBarsColors();
// UIUtils.setPaddingForSystemBars(this, findViewById(android.R.id.content), true, true, true);
// UIUtils.setPaddingForSystemBars(this, findViewById(R.id.fragment_container), true, true, true);
}
@Override

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment_container">
</FrameLayout>