Fixing scrollTo getting called even though the gesture was handled by an overlay

Change-Id: Ia46c4ef3db8a3ae4fa615625b7b983d7e461c797
This commit is contained in:
Sunny Goyal
2016-02-29 15:15:03 -08:00
parent f7aa6053ee
commit 061380a04d
2 changed files with 26 additions and 6 deletions
+1 -1
View File
@@ -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;
+25 -5
View File
@@ -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;