Disabling synchronous binding when returning home from another app while orientation has changed. (Bug 6792288)

- Fixing issue where we were reverting to the first page of the workspace after launching an application from all apps, rotating, and returning home
- Enabling rotation in master.

Change-Id: I291b9d76b20244e9028b6f62164430bc3606644c
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 40ec7ca..1b79c9b 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1653,7 +1653,8 @@
                 return;
             }
 
-            final int currentScreen = (synchronizeBindPage > -1) ? synchronizeBindPage :
+            final boolean isLoadingSynchronously = (synchronizeBindPage > -1);
+            final int currentScreen = isLoadingSynchronously ? synchronizeBindPage :
                 oldCallbacks.getCurrentWorkspaceScreen();
 
             // Load all the items that are on the current page first (and in the process, unbind
@@ -1705,10 +1706,11 @@
             bindWorkspaceItems(oldCallbacks, currentWorkspaceItems, currentAppWidgets,
                     currentFolders, null);
 
-            // Load all the remaining pages
+            // Load all the remaining pages (if we are loading synchronously, we want to defer this
+            // work until after the first render)
             mDeferredBindRunnables.clear();
             bindWorkspaceItems(oldCallbacks, otherWorkspaceItems, otherAppWidgets, otherFolders,
-                    mDeferredBindRunnables);
+                    (isLoadingSynchronously ? mDeferredBindRunnables : null));
 
             // Tell the workspace that we're done binding items
             r = new Runnable() {
@@ -1727,7 +1729,11 @@
                     mIsLoadingAndBindingWorkspace = false;
                 }
             };
-            mDeferredBindRunnables.add(r);
+            if (isLoadingSynchronously) {
+                mDeferredBindRunnables.add(r);
+            } else {
+                runOnMainThread(r);
+            }
         }
 
         private void loadAndBindAllApps() {