Correctly initialize mSingleAccountMode

This fixes a NullPointerException when trying to open account settings
from the Unified Inbox (when there's only one account).
This commit is contained in:
cketti 2013-05-27 16:59:07 +02:00
parent ed354eea32
commit 34812fa5b8

View file

@ -439,19 +439,27 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
}
}
Preferences prefs = Preferences.getPreferences(getApplicationContext());
String[] accountUuids = mSearch.getAccountUuids();
mSingleAccountMode = (accountUuids.length == 1 && !mSearch.searchAllAccounts());
if (mSearch.searchAllAccounts()) {
Account[] accounts = prefs.getAccounts();
mSingleAccountMode = (accounts.length == 1);
if (mSingleAccountMode) {
mAccount = accounts[0];
}
} else {
mSingleAccountMode = (accountUuids.length == 1);
if (mSingleAccountMode) {
mAccount = prefs.getAccount(accountUuids[0]);
}
}
mSingleFolderMode = mSingleAccountMode && (mSearch.getFolderNames().size() == 1);
if (mSingleAccountMode) {
Preferences prefs = Preferences.getPreferences(getApplicationContext());
mAccount = prefs.getAccount(accountUuids[0]);
if (mAccount != null && !mAccount.isAvailable(this)) {
Log.i(K9.LOG_TAG, "not opening MessageList of unavailable account");
onAccountUnavailable();
return;
}
if (mSingleAccountMode && (mAccount == null || !mAccount.isAvailable(this))) {
Log.i(K9.LOG_TAG, "not opening MessageList of unavailable account");
onAccountUnavailable();
return;
}
if (mSingleFolderMode) {