Merge "update account spinner properly"

This commit is contained in:
Todd Kennedy 2011-06-07 17:52:32 -07:00 committed by Android (Google) Code Review
commit 32d45f6669
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;
}