Fading in the first screen, when launcher loads for the first time

Bug: 29007436
Bug: 27705838
Change-Id: I95891d0bad19a67985b689bb96d6068dcd85004a
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d668d2a..df856c1 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -465,7 +465,11 @@
             } else {
                 // We only load the page synchronously if the user rotates (or triggers a
                 // configuration change) while launcher is in the foreground
-                mModel.startLoader(mWorkspace.getRestorePage());
+                if (!mModel.startLoader(mWorkspace.getRestorePage())) {
+                    // If we are not binding synchronously, show a fade in animation when
+                    // the first page bind completes.
+                    mDragLayer.setAlpha(0);
+                }
             }
         }
 
@@ -4003,6 +4007,32 @@
         }
     }
 
+    @Override
+    public void finishFirstPageBind(final ViewOnDrawExecutor executor) {
+        Runnable r = new Runnable() {
+            public void run() {
+                finishFirstPageBind(executor);
+            }
+        };
+        if (waitUntilResume(r)) {
+            return;
+        }
+
+        Runnable onComplete = new Runnable() {
+            @Override
+            public void run() {
+                if (executor != null) {
+                    executor.onLoadAnimationCompleted();
+                }
+            }
+        };
+        if (mDragLayer.getAlpha() < 1) {
+            mDragLayer.animate().alpha(1).withEndAction(onComplete).start();
+        } else {
+            onComplete.run();
+        }
+    }
+
     /**
      * Callback saying that there aren't any more items to bind.
      *