Fixing the loader to bind the first screen as well as the hotseat together

When the loader ran for the first time (or when called due to force-reload),
it was binding with page = -1 (invalid pageId is -1001). This was causing loader
to assume the workspace to be on a valid screen, and causing the loader to
only bind the hotseat first.

Bug: 27705838
Change-Id: Ia8eb2543d8cee1268256b2d6bccf33828937c54a
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 3c7366c..9208d32 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1266,17 +1266,13 @@
      * of doing it now.
      */
     public void startLoaderFromBackground() {
-        boolean runLoader = false;
         Callbacks callbacks = getCallback();
         if (callbacks != null) {
             // Only actually run the loader if they're not paused.
             if (!callbacks.setLoadOnResume()) {
-                runLoader = true;
+                startLoader(callbacks.getCurrentWorkspaceScreen());
             }
         }
-        if (runLoader) {
-            startLoader(PagedView.INVALID_RESTORE_PAGE);
-        }
     }
 
     /**
@@ -1313,7 +1309,7 @@
 
                 // If there is already one running, tell it to stop.
                 stopLoaderLocked();
-                mLoaderTask = new LoaderTask(mApp.getContext(), loadFlags);
+                mLoaderTask = new LoaderTask(mApp.getContext(), loadFlags, synchronousBindPage);
                 if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE
                         && mAllAppsLoaded && mWorkspaceLoaded && !mIsLoaderTaskRunning) {
                     mLoaderTask.runBindSynchronousPage(synchronousBindPage);
@@ -1367,14 +1363,17 @@
      */
     private class LoaderTask implements Runnable {
         private Context mContext;
+        private int mPageToBindFirst;
+
         @Thunk boolean mIsLoadingAndBindingWorkspace;
         private boolean mStopped;
         @Thunk boolean mLoadAndBindStepFinished;
         private int mFlags;
 
-        LoaderTask(Context context, int flags) {
+        LoaderTask(Context context, int flags, int pageToBindFirst) {
             mContext = context;
             mFlags = flags;
+            mPageToBindFirst = pageToBindFirst;
         }
 
         private void loadAndBindWorkspace() {
@@ -1396,7 +1395,7 @@
             }
 
             // Bind the workspace
-            bindWorkspace(-1);
+            bindWorkspace(mPageToBindFirst);
         }
 
         private void waitForIdle() {