Merge "Again, get sync() off UI thread"
diff --git a/src/com/android/mail/browse/ConversationCursor.java b/src/com/android/mail/browse/ConversationCursor.java
index 0fed972..ebc1440 100644
--- a/src/com/android/mail/browse/ConversationCursor.java
+++ b/src/com/android/mail/browse/ConversationCursor.java
@@ -157,7 +157,6 @@
                     if (sRefreshReady) {
                         // If we already have a refresh ready, just sync() it
                         LogUtils.i(TAG, "Create: refreshed cursor ready, sync");
-                        sConversationCursor.sync();
                     } else {
                         // Position the cursor before the first item (as it would be if new), reset
                         // the cache, and return as new
@@ -172,7 +171,7 @@
                     // Set qUri/qProjection these in case they changed
                     LogUtils.i(TAG, "Create: new query or refresh needed, query/sync");
                     sRequeryCursor = doQuery(uri, projection);
-                    sConversationCursor.sync();
+                    sRefreshReady = true;
                 }
                 return sConversationCursor;
             }
@@ -206,6 +205,10 @@
         return false;
     }
 
+    static boolean offUiThread() {
+        return Looper.getMainLooper().getThread() != Thread.currentThread();
+    }
+
     /**
      * Reset the cursor; this involves clearing out our cache map and resetting our various counts
      * The cursor should be reset whenever we get fresh data from the underlying cursor. The cache
@@ -881,10 +884,6 @@
             }
         }
 
-        static boolean offUiThread() {
-            return Looper.getMainLooper().getThread() != Thread.currentThread();
-        }
-
         public int apply(ArrayList<ConversationOperation> ops) {
             final HashMap<String, ArrayList<ContentProviderOperation>> batchMap =
                     new HashMap<String, ArrayList<ContentProviderOperation>>();
diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java
index 8734ce1..16eb391 100644
--- a/src/com/android/mail/ui/ConversationListFragment.java
+++ b/src/com/android/mail/ui/ConversationListFragment.java
@@ -521,6 +521,9 @@
     @Override
     public void onLoadFinished(Loader<ConversationCursor> loader, ConversationCursor data) {
         mConversationListCursor = data;
+        if (mConversationListCursor.isRefreshReady()) {
+            mConversationListCursor.sync();
+        }
         mListAdapter.swapCursor(mConversationListCursor);
         mConversationListCursor.addListener(this);
         updateSearchResultHeader(data != null ? data.getCount() : 0);
diff --git a/src/com/android/mail/ui/RecentFolderList.java b/src/com/android/mail/ui/RecentFolderList.java
index ed5aa0b..ad59764 100644
--- a/src/com/android/mail/ui/RecentFolderList.java
+++ b/src/com/android/mail/ui/RecentFolderList.java
@@ -28,10 +28,10 @@
 import com.android.mail.utils.LogUtils;
 import com.android.mail.utils.LruCache;
 
-import java.util.Collections;
 import java.util.ArrayList;
-import java.util.List;
+import java.util.Collections;
 import java.util.Comparator;
+import java.util.List;
 
 /**
  * A self-updating list of folder canonical names for the N most recently touched folders, ordered
@@ -135,8 +135,8 @@
             values.put(id, now);
         }
         final ContentResolver mResolver = mContext.getContentResolver();
-        if (mAccount.recentFolderListUri != null
-                && !TextUtils.equals("null", mAccount.recentFolderListUri.toString())) {
+        // TODO: Remove this test
+        if (!TextUtils.equals("null", mAccount.recentFolderListUri.toString())) {
             mResolver.update(mAccount.recentFolderListUri, values, null, null);
         }
     }