update account spinner properly

Fixes two issues:
1. if a recent folder was selected from the spinner, the user could not
re-select it (even if they navigated to another mailbox using the mailbox
list) unless they manually selected another element in the spinner
2. the recent item "show all folders" did not set the associated account
position, so, when selecting that item, the spinner was not showing the
correct view.

Change-Id: I469f9f28aebd36a348534def28a4c476c0df366d
This commit is contained in:
Todd Kennedy 2011-06-07 17:12:34 -07:00
parent dc6928d798
commit 7305cf5c8e
2 changed files with 8 additions and 2 deletions

View File

@ -210,7 +210,7 @@ public class AccountSelectorAdapter extends CursorAdapter {
return c.moveToPosition(position) ? getAccountUnreadCount(c) : 0;
}
private int getAccountPosition(int position) {
int getAccountPosition(int position) {
final Cursor c = getCursor();
return c.moveToPosition(position) ? getAccountPosition(c) : UNKNOWN_POSITION;
}
@ -358,7 +358,7 @@ public class AccountSelectorAdapter extends CursorAdapter {
String name = mContext.getString(
R.string.mailbox_list_account_selector_show_all_folders);
addRow(matrixCursor, ROW_TYPE_MAILBOX, Mailbox.NO_MAILBOX, name, null, 0,
UNKNOWN_POSITION);
accountPosition);
}
}

View File

@ -238,6 +238,12 @@ public class ActionBarController {
mCallback.onAccountSelected(itemId);
} else if (!mAccountsSelectorAdapter.isAccountItem(itemPosition)) {
mCallback.onMailboxSelected(itemId);
// We need to update the selection, otherwise the user is unable to select the
// recent folder a second time w/o first selecting another item in the spinner
int selectedPosition = mAccountsSelectorAdapter.getAccountPosition(itemPosition);
if (selectedPosition != AccountSelectorAdapter.UNKNOWN_POSITION) {
mActionBar.setSelectedNavigationItem(selectedPosition);
}
}
return true;
}