|
@@ -71,6 +71,11 @@ public class MainActivity extends Activity {
|
|
|
*/
|
|
|
public Fragment mDisplayedFragment;
|
|
|
|
|
|
+ /**
|
|
|
+ * The currently displayed fragment index
|
|
|
+ */
|
|
|
+ public int mDisplayedFragmentIndex;
|
|
|
+
|
|
|
/**
|
|
|
* Holds the Hostage Service
|
|
|
*/
|
|
@@ -313,9 +318,26 @@ public class MainActivity extends Activity {
|
|
|
if (savedInstanceState == null) {
|
|
|
// on first time display view for first nav item
|
|
|
displayView(0);
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ mDisplayedFragmentIndex = savedInstanceState.getInt("mDisplayedFragmentIndex");
|
|
|
+ mDisplayedFragment = getFragmentManager().getFragment(savedInstanceState, "mDisplayedFragment");
|
|
|
+
|
|
|
+ mDrawerList.setItemChecked(mDisplayedFragmentIndex, true);
|
|
|
+ mDrawerList.setSelection(mDisplayedFragmentIndex);
|
|
|
+ setTitle(mDrawerItems.get(mDisplayedFragmentIndex).text);
|
|
|
+
|
|
|
+ injectFragment(mDisplayedFragment);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onSaveInstanceState(Bundle outState){
|
|
|
+ super.onSaveInstanceState(outState);
|
|
|
+
|
|
|
+ outState.putInt("mDisplayedFragmentIndex", mDisplayedFragmentIndex);
|
|
|
+ getFragmentManager().putFragment(outState, "mDisplayedFragment", mDisplayedFragment);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Displays the disclaimer on first run of the application
|
|
|
*/
|
|
@@ -515,6 +537,7 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
injectFragment(fragment);
|
|
|
|
|
|
+ mDisplayedFragmentIndex = position;
|
|
|
mDrawerList.setItemChecked(position, true);
|
|
|
mDrawerList.setSelection(position);
|
|
|
setTitle(mDrawerItems.get(position).text);
|