mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
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:
parent
ed354eea32
commit
34812fa5b8
@ -439,19 +439,27 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
||||||
|
|
||||||
String[] accountUuids = mSearch.getAccountUuids();
|
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);
|
mSingleFolderMode = mSingleAccountMode && (mSearch.getFolderNames().size() == 1);
|
||||||
|
|
||||||
if (mSingleAccountMode) {
|
if (mSingleAccountMode && (mAccount == null || !mAccount.isAvailable(this))) {
|
||||||
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
Log.i(K9.LOG_TAG, "not opening MessageList of unavailable account");
|
||||||
mAccount = prefs.getAccount(accountUuids[0]);
|
onAccountUnavailable();
|
||||||
|
return;
|
||||||
if (mAccount != null && !mAccount.isAvailable(this)) {
|
|
||||||
Log.i(K9.LOG_TAG, "not opening MessageList of unavailable account");
|
|
||||||
onAccountUnavailable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSingleFolderMode) {
|
if (mSingleFolderMode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user