diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index b3a714b81f..a290f5feff 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -149,7 +149,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc 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 e983e79762..1193fe7e4f 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1234,16 +1234,36 @@ public class Workspace extends PagedView @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;