Fix edge case where LauncherOverlay scroll woudln't be reset
-> If the Workspace has a single page and the user goes from overscrolling
in one direction, and then the other, the LauncherOverlay scroll wouldn't
be set to 0 until the scrolling settled
Change-Id: I29ee9abdfa023ae3599d1590cdaebf457e2220fa
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 518ee97..66d4ac0 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -295,6 +295,7 @@
boolean mScrollInteractionBegan;
boolean mStartedSendingScrollEvents;
boolean mShouldSendPageSettled;
+ int mLastOverlaySroll = 0;
private final Runnable mBindPages = new Runnable() {
@Override
@@ -1287,8 +1288,11 @@
boolean shouldOverScroll = (amount <= 0 && (!hasCustomContent() || isRtl)) ||
(amount >= 0 && (!hasCustomContent() || !isRtl));
- boolean shouldScrollOverlay = (amount <= 0 && mLauncherOverlay != null && !isRtl) ||
- (amount >= 0 && mLauncherOverlay != null && isRtl);
+ boolean shouldScrollOverlay = mLauncherOverlay != null &&
+ ((amount <= 0 && !isRtl) || (amount >= 0 && isRtl));
+
+ boolean shouldZeroOverlay = mLauncherOverlay != null && mLastOverlaySroll != 0 &&
+ ((amount >= 0 && !isRtl) || (amount <= 0 && isRtl));
if (shouldScrollOverlay) {
if (!mStartedSendingScrollEvents && mScrollInteractionBegan) {
@@ -1301,6 +1305,7 @@
int progress = (int) Math.abs((f * 100));
+ mLastOverlaySroll = progress;
mLauncherOverlay.onScrollChange(progress, isRtl);
} else if (shouldOverScroll) {
dampedOverScroll(amount);
@@ -1308,6 +1313,10 @@
} else {
mOverScrollEffect = 0;
}
+
+ if (shouldZeroOverlay) {
+ mLauncherOverlay.onScrollChange(0, isRtl);
+ }
}
@Override