diff --git a/astrid/src/com/todoroo/astrid/activity/AstridWrapperActivity.java b/astrid/src/com/todoroo/astrid/activity/AstridWrapperActivity.java index 900d911ba..1d1319d7d 100644 --- a/astrid/src/com/todoroo/astrid/activity/AstridWrapperActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/AstridWrapperActivity.java @@ -86,8 +86,7 @@ public class AstridWrapperActivity extends FragmentActivity */ public boolean onFilterItemClicked(FilterListItem item) { if (this instanceof TaskListWrapperActivity) { - int selectedPosition = ((TaskListWrapperActivity) this).getFilterItemPosition(item); - getSupportActionBar().setSelectedNavigationItem(selectedPosition); + ((TaskListWrapperActivity) this).setSelectedItem(item); } if (!mMultipleFragments || (item instanceof SearchFilter)) { if(item instanceof Filter) { diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListWrapperActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListWrapperActivity.java index a177d9f75..b95a0edc0 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListWrapperActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListWrapperActivity.java @@ -13,6 +13,9 @@ import com.todoroo.astrid.service.ThemeService; public class TaskListWrapperActivity extends AstridWrapperActivity { + public static final String TOKEN_SELECTED_FILTER = "selectedFilter"; + private int selectionToSet; + private ArrayAdapter listDropdownAdapter; /** * @see android.app.Activity#onCreate(Bundle) @@ -30,6 +33,11 @@ public class TaskListWrapperActivity extends AstridWrapperActivity { ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); + + if (savedInstanceState != null) { + selectionToSet = savedInstanceState.getInt(TOKEN_SELECTED_FILTER); + } + } /* (non-Javadoc) @@ -57,10 +65,21 @@ public class TaskListWrapperActivity extends AstridWrapperActivity { return true; } }); + if (selectionToSet != -1 && selectionToSet < listDropdownAdapter.getCount()) { + selectionToSet = -1; + getSupportActionBar().setSelectedNavigationItem(selectionToSet); + } + } + + @Override + protected void onSaveInstanceState(Bundle icicle) { + icicle.putInt(TOKEN_SELECTED_FILTER, getSupportActionBar().getSelectedNavigationIndex()); + super.onSaveInstanceState(icicle); } - public int getFilterItemPosition(FilterListItem item) { - return listDropdownAdapter.getPosition(item); + public void setSelectedItem(FilterListItem item) { + int position = listDropdownAdapter.getPosition(item); + getSupportActionBar().setSelectedNavigationItem(position); } @Override