Fixing scrollTo getting called even though the gesture was handled by an overlay
Change-Id: Ia46c4ef3db8a3ae4fa615625b7b983d7e461c797
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index b3a714b..a290f5f 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -149,7 +149,7 @@
protected boolean mIsPageMoving = false;
- private boolean mWasInOverscroll = false;
+ protected boolean mWasInOverscroll = false;
// Page Indicator
@Thunk int mPageIndicatorViewId;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index e983e79..1193fe7 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1234,16 +1234,36 @@
@Override
protected int getUnboundedScrollX() {
- if (mLauncherOverlay != null) {
- if ((mIsRtl && mUnboundedScrollX > mMaxScrollX) ||
- (!mIsRtl && mUnboundedScrollX < 0)) {
- return mUnboundedScrollX;
- }
+ if (isScrollingOverlay()) {
+ return mUnboundedScrollX;
}
return super.getUnboundedScrollX();
}
+ private boolean isScrollingOverlay() {
+ return mLauncherOverlay != null &&
+ ((mIsRtl && mUnboundedScrollX > mMaxScrollX) || (!mIsRtl && mUnboundedScrollX < 0));
+ }
+
+ @Override
+ protected void snapToDestination() {
+ // If we're overscrolling the overlay, we make sure to immediately reset the PagedView
+ // to it's baseline position instead of letting the overscroll settle. The overlay handles
+ // it's own settling, and every gesture to the overlay should be self-contained and start
+ // from 0, so we zero it out here.
+ if (isScrollingOverlay()) {
+ int finalScroll = mIsRtl ? mMaxScrollX : 0;
+
+ // We reset mWasInOverscroll so that PagedView doesn't zero out the overscroll
+ // interaction when we call scrollTo.
+ mWasInOverscroll = false;
+ scrollTo(finalScroll, getScrollY());
+ } else {
+ super.snapToDestination();
+ }
+ }
+
@Override
public void scrollTo(int x, int y) {
mUnboundedScrollX = x;