Update screen properly when # of accounts becomes 1 from 2
This happens when - two accounts are configured - select account 1 - remove account 1, and account 2 becomes active In this case we failed to select account 2, and the fragments would keep thinking account 1 was active. (So no mailboxes would be shown--beacuse there was of course no mailboxes for account 1!) When the account list changes, the account loader (created in loadAccounts()) automatically reloads the account list, and calls updateAccountList(). If there're still more than 1 account at this point, updateAccountList() updates the account spinner on the action bar. This will result in ActionBarNavigationCallback getting called, which then updates the current account as expected. However, if there's only one account left, we hide the spinner and just set the account name to the action bar title, so ActionBarNavigationCallback won't get called and the current account never changes. In this case we shouldn't rely on ActionBarNavigationCallback but have to explicitly update the current account. Bug 3491567 Change-Id: Ia9ba3e1c11248ad5a1ba7e055717c5519d6e4884
This commit is contained in:
parent
b02f7eb1e8
commit
fc156033d9
|
@ -647,6 +647,8 @@ public class MessageListXL extends Activity implements
|
|||
ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
|
||||
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
ab.setTitle(AccountSelectorAdapter.getAccountDisplayName(accountsCursor));
|
||||
|
||||
selectAccount(AccountSelectorAdapter.getAccountId(accountsCursor));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -675,13 +677,17 @@ public class MessageListXL extends Activity implements
|
|||
ab.setSelectedNavigationItem(defaultSelection);
|
||||
}
|
||||
|
||||
private void selectAccount(long accountId) {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "Account selected: accountId=" + accountId);
|
||||
}
|
||||
mFragmentManager.selectAccount(accountId, -1, -1);
|
||||
}
|
||||
|
||||
private class ActionBarNavigationCallback implements ActionBar.OnNavigationListener {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(int itemPosition, long accountId) {
|
||||
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "Account selected: accountId=" + accountId);
|
||||
}
|
||||
mFragmentManager.selectAccount(accountId, -1, -1);
|
||||
selectAccount(accountId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue