Fix empty recent folders
Plus, avoid restarting the loader twice (setAccount already does this).
Bug: 7203516 Gmail: no recent labels shown
Change-Id: I8d108094a850bfae893782529d9dce0257fdb884
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index e4cf09f..6106150 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -1589,7 +1589,6 @@
mViewMode.enterSearchResultsListMode();
}
setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT));
- restartOptionalLoader(LOADER_RECENT_FOLDERS);
fetchSearchFolder(intent);
} else {
LogUtils.e(LOG_TAG, "Missing account extra from search intent. Finishing");
diff --git a/src/com/android/mail/ui/RecentFolderList.java b/src/com/android/mail/ui/RecentFolderList.java
index c49a0f3..87d916a 100644
--- a/src/com/android/mail/ui/RecentFolderList.java
+++ b/src/com/android/mail/ui/RecentFolderList.java
@@ -146,8 +146,12 @@
* @param account the new current account
*/
private void setCurrentAccount(Account account) {
+ final boolean accountSwitched = (mAccount == null) || account.uri.equals(mAccount.uri);
mAccount = account;
- mFolderCache.clear();
+ // Clear the cache only if we moved from alice@example.com -> alice@work.com
+ if (accountSwitched) {
+ mFolderCache.clear();
+ }
}
/**
@@ -156,12 +160,13 @@
*/
public void loadFromUiProvider(Cursor c) {
if (mAccount == null || c == null) {
+ LogUtils.e(TAG, "RecentFolderList.loadFromUiProvider: bad input. mAccount=%s,cursor=%s",
+ mAccount, c);
return;
}
LogUtils.d(TAG, "Number of recents = %d", c.getCount());
- int i = 0;
if (!c.moveToLast()) {
- LogUtils.d(TAG, "Not able to move to last in recent labels cursor");
+ LogUtils.e(TAG, "Not able to move to last in recent labels cursor");
return;
}
// Add them backwards, since the most recent values are at the beginning in the cursor.