Merge "Fix account picker crash when there is no account before."

This commit is contained in:
Lei Yu
2016-12-12 21:06:11 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 2 deletions

View File

@@ -170,8 +170,13 @@ public final class SupportItemAdapter extends RecyclerView.Adapter<SupportItemAd
public void setAccounts(Account accounts[]) {
if (!Arrays.equals(mAccounts, accounts)) {
int index = ArrayUtils.indexOf(accounts, mAccounts[mSelectedAccountIndex]);
mSelectedAccountIndex = index != -1 ? index : 0;
if (mAccounts.length == 0) {
mSelectedAccountIndex = 0;
} else {
final int index = ArrayUtils.indexOf(accounts, mAccounts[mSelectedAccountIndex]);
mSelectedAccountIndex = index != -1 ? index : 0;
}
mAccounts = accounts;
mSupportFeatureProvider.refreshOperationRules();
refreshEscalationCards();