Do not reset the recent folder list on folder access.
Change-Id: I76dafa896d63f46cfd7f91cb1393560e70443b5f
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index ccac207..ca2a10e 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -33,7 +33,6 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -395,16 +394,18 @@
}
}
+ /**
+ * Update the recent folders. This only needs to be done once when accessing a new folder.
+ */
private void updateRecentFolderList() {
if (mFolder != null) {
- mRecentFolderList.setCurrentAccount(mAccount);
mRecentFolderList.touchFolder(mFolder);
}
}
// TODO(mindyp): set this up to store a copy of the folder as a transient
// field in the account.
- public void loadAccountInbox() {
+ protected void loadAccountInbox() {
restartOptionalLoader(LOADER_ACCOUNT_INBOX, null);
}
diff --git a/src/com/android/mail/ui/RecentFolderList.java b/src/com/android/mail/ui/RecentFolderList.java
index 39a218a..3e1b996 100644
--- a/src/com/android/mail/ui/RecentFolderList.java
+++ b/src/com/android/mail/ui/RecentFolderList.java
@@ -78,17 +78,20 @@
final Account mAccount;
final Folder mFolder;
+ /**
+ * Create a new asynchronous task to store the recent folder list. Both the account
+ * and the folder should be non-null.
+ * @param account
+ * @param folder
+ */
public StoreRecent(Account account, Folder folder) {
+ assert (account != null && folder != null);
mAccount = account;
mFolder = folder;
}
@Override
protected Void doInBackground(Void... v) {
- if (mAccount == null) {
- LogUtils.w(TAG, "No account set for setting recent folders?");
- return null;
- }
Uri uri = mAccount.recentFolderListUri;
if (uri != null) {
ContentValues values = new ContentValues();
@@ -144,10 +147,17 @@
/**
* Marks the given folder as 'accessed' by the user interface, its entry is updated in the
- * recent folder list, and the current time is written to the provider
+ * recent folder list, and the current time is written to the provider. This should never
+ * be called with a null folder.
* @param folder the folder we touched
*/
public void touchFolder(Folder folder) {
+ // We haven't got a valid account yet, cannot proceed.
+ if (mAccount == null) {
+ LogUtils.w(TAG, "No account set for setting recent folders?");
+ return;
+ }
+ assert (folder != null);
mFolderCache.putElement(folder.uri.toString(), folder);
new StoreRecent(mAccount, folder).execute();
}