Merge "Adding custom content scroll progress callback" into jb-ub-gel-agar
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7970b71..509560c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -919,6 +919,9 @@
 
         // Custom content is completely hidden
         public void onHide();
+
+        // Custom content scroll progress changed. From 0 (not showing) to 1 (fully showing).
+        public void onScrollProgressChanged(float progress);
     }
 
     protected void startSettings() {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index b6ef27d..339f0ab 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -134,6 +134,7 @@
 
     CustomContentCallbacks mCustomContentCallbacks;
     boolean mCustomContentShowing;
+    private float mLastCustomContentScrollProgress = -1f;
 
     /**
      * The CellLayout that is currently being dragged over
@@ -1258,6 +1259,9 @@
                     (getScrollForPage(index + 1) - getScrollForPage(index));
             progress = Math.max(0, progress);
 
+            if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
+            mLastCustomContentScrollProgress = progress;
+
             setBackgroundAlpha(progress * 0.8f);
             float height = getViewportHeight();
             if (getPageIndicator() != null) {
@@ -1271,6 +1275,7 @@
                 mLauncher.getHotseat().setTranslationY(transY);
                 mLauncher.getHotseat().setAlpha(1 - progress);
             }
+
             if (getPageIndicator() != null) {
                 final float alpha = 1 - progress;
                 final View pi = getPageIndicator();
@@ -1281,6 +1286,10 @@
                     pi.setVisibility(VISIBLE);
                 }
             }
+
+            if (mCustomContentCallbacks != null) {
+                mCustomContentCallbacks.onScrollProgressChanged(progress);
+            }
         }
     }