mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-22 07:58:20 -05:00
DownloadActivity remembers your category on rotate
This commit is contained in:
parent
23c41ddb72
commit
0caca67f44
@ -28,6 +28,8 @@ public class DownloadActivity extends BaseActivity implements
|
|||||||
Injector {
|
Injector {
|
||||||
|
|
||||||
private final String TAG = "DownloadActivity";
|
private final String TAG = "DownloadActivity";
|
||||||
|
private final String TAG_CURRENT_CATEGORY = "CurrentCategory";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("ValidCategories")
|
@Named("ValidCategories")
|
||||||
List<BookCategory> validCategories;
|
List<BookCategory> validCategories;
|
||||||
@ -41,6 +43,7 @@ public class DownloadActivity extends BaseActivity implements
|
|||||||
* {@link #restoreActionBar()}.
|
* {@link #restoreActionBar()}.
|
||||||
*/
|
*/
|
||||||
private CharSequence mTitle;
|
private CharSequence mTitle;
|
||||||
|
|
||||||
private ObjectGraph daObjectGraph;
|
private ObjectGraph daObjectGraph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +85,13 @@ public class DownloadActivity extends BaseActivity implements
|
|||||||
// Set up the drawer.
|
// Set up the drawer.
|
||||||
mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
|
mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
|
||||||
(DrawerLayout) findViewById(R.id.drawer_layout));
|
(DrawerLayout) findViewById(R.id.drawer_layout));
|
||||||
mNavigationDrawerFragment.selectItem(0);
|
|
||||||
|
// And select our first item
|
||||||
|
int itemToSelect = 0;
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
itemToSelect = savedInstanceState.getInt(TAG_CURRENT_CATEGORY);
|
||||||
|
}
|
||||||
|
mNavigationDrawerFragment.selectItem(itemToSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -132,5 +141,10 @@ public class DownloadActivity extends BaseActivity implements
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putInt(TAG_CURRENT_CATEGORY,
|
||||||
|
mNavigationDrawerFragment.getCurrentPosition());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,8 @@ public class NavDrawerFragment extends AbstractNavDrawerFragment {
|
|||||||
mCallbacks.onNavigationDrawerItemSelected(position);
|
mCallbacks.onNavigationDrawerItemSelected(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCurrentPosition() {
|
||||||
|
return mCurrentSelectedPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user