Adding custom content scroll progress callback
Change-Id: I23b007f6ac30809c03127f5d9030d8f367694310
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 35e166f..e855679 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);
}
public interface QSBScroller {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 05f9e2d..458c4e7 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
@@ -1233,6 +1234,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) {
@@ -1246,6 +1250,7 @@
mLauncher.getHotseat().setTranslationY(transY);
mLauncher.getHotseat().setAlpha(1 - progress);
}
+
if (getPageIndicator() != null) {
final float alpha = 1 - progress;
final View pi = getPageIndicator();
@@ -1256,6 +1261,10 @@
pi.setVisibility(VISIBLE);
}
}
+
+ if (mCustomContentCallbacks != null) {
+ mCustomContentCallbacks.onScrollProgressChanged(progress);
+ }
}
}