Fixing scrollTo getting called even though the gesture was handled by an overlay
Change-Id: Ia46c4ef3db8a3ae4fa615625b7b983d7e461c797
(cherry picked from commit 061380a04d)
This commit is contained in:
@@ -156,7 +156,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;
|
||||
|
||||
@@ -1261,16 +1261,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;
|
||||
|
||||
Reference in New Issue
Block a user