Make sure sync() happens in UI thread

Bug: 6134215
Change-Id: Ib4678108eeb3e51b59ddfdc30a2b9bdabb7d1723
diff --git a/src/com/android/mail/browse/ConversationCursor.java b/src/com/android/mail/browse/ConversationCursor.java
index 0fed972..f0a11bc 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;
             }
diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java
index 8734ce1..2fe0237 100644
--- a/src/com/android/mail/ui/ConversationListFragment.java
+++ b/src/com/android/mail/ui/ConversationListFragment.java
@@ -521,6 +521,10 @@
     @Override
     public void onLoadFinished(Loader<ConversationCursor> loader, ConversationCursor data) {
         mConversationListCursor = data;
+        // Sync if necessary
+        if (mConversationListCursor.isRefreshReady()) {
+            onRefreshReady();
+        }
         mListAdapter.swapCursor(mConversationListCursor);
         mConversationListCursor.addListener(this);
         updateSearchResultHeader(data != null ? data.getCount() : 0);