diff options
Diffstat (limited to 'src/com/android/launcher3/PagedView.java')
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 48fc0c98f..7d65f4686 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -204,6 +204,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc protected boolean mAllowLongPress = true; + private boolean mWasInOverscroll = false; + // Page Indicator private int mPageIndicatorViewId; private PageIndicator mPageIndicator; @@ -625,6 +627,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc // a method that subclasses can override to add behavior protected void onPageEndMoving() { + mWasInOverscroll = false; } /** @@ -663,6 +666,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc if (isXBeforeFirstPage) { super.scrollTo(0, y); if (mAllowOverScroll) { + mWasInOverscroll = true; if (isRtl) { overScroll(x - mMaxScrollX); } else { @@ -672,6 +676,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } else if (isXAfterLastPage) { super.scrollTo(mMaxScrollX, y); if (mAllowOverScroll) { + mWasInOverscroll = true; if (isRtl) { overScroll(x); } else { @@ -679,6 +684,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } } } else { + if (mWasInOverscroll) { + overScroll(0); + mWasInOverscroll = false; + } mOverScrollX = x; super.scrollTo(x, y); } @@ -1513,6 +1522,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mLastMotionXRemainder = 0; mTouchX = getViewportOffsetX() + getScrollX(); mSmoothingTime = System.nanoTime() / NANOTIME_DIV; + onScrollInteractionBegin(); pageBeginMoving(); } } @@ -1752,6 +1762,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mActivePointerId = ev.getPointerId(0); if (mTouchState == TOUCH_STATE_SCROLLING) { + onScrollInteractionBegin(); pageBeginMoving(); } break; @@ -1940,6 +1951,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc getScrollY(), vX, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 0); invalidate(); } + onScrollInteractionEnd(); } else if (mTouchState == TOUCH_STATE_PREV_PAGE) { // at this point we have not moved beyond the touch slop // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so @@ -2025,6 +2037,15 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc mActivePointerId = INVALID_POINTER; } + /** + * Triggered by scrolling via touch + */ + protected void onScrollInteractionBegin() { + } + + protected void onScrollInteractionEnd() { + } + protected void onUnhandledTap(MotionEvent ev) { ((Launcher) getContext()).onClick(this); } |