diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-05-02 20:44:06 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-02 20:44:06 +0000 |
commit | f1db5a0b812f341478ca558923bf0c8a0dbea01b (patch) | |
tree | ae1bd57c1bc5f10f32d85ae1c661f255a937a41b | |
parent | d79759556d33639be1ea45d3a511a20910dbd600 (diff) | |
parent | a9283beebc0755bbbc4b40d38530c2fdc33e2532 (diff) | |
download | android_packages_apps_Trebuchet-f1db5a0b812f341478ca558923bf0c8a0dbea01b.tar.gz android_packages_apps_Trebuchet-f1db5a0b812f341478ca558923bf0c8a0dbea01b.tar.bz2 android_packages_apps_Trebuchet-f1db5a0b812f341478ca558923bf0c8a0dbea01b.zip |
Merge "Settling scrolls over clear-all button." into ub-launcher3-edmonton
-rw-r--r-- | src/com/android/launcher3/PagedView.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 8311ab9a7..87ee076f3 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -1171,11 +1171,19 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou mNextPage = getPageNearestToCenterOfScreen(unscaledScrollX); int firstPageScroll = getScrollForPage(!mIsRtl ? 0 : getPageCount() - 1); int lastPageScroll = getScrollForPage(!mIsRtl ? getPageCount() - 1 : 0); - if (mSettleOnPageInFreeScroll && unscaledScrollX > firstPageScroll - && unscaledScrollX < lastPageScroll) { - // Make sure we land directly on a page. If flinging past one of the ends, - // don't change the velocity as it will get stopped at the end anyway. - mScroller.setFinalX((int) (getScrollForPage(mNextPage) * getScaleX())); + if (mSettleOnPageInFreeScroll && unscaledScrollX > 0 + && unscaledScrollX < mMaxScrollX) { + // If scrolling ends in the half of the added space that is closer to the + // end, settle to the end. Otherwise snap to the nearest page. + // If flinging past one of the ends, don't change the velocity as it will + // get stopped at the end anyway. + final int finalX = unscaledScrollX < firstPageScroll / 2 ? + 0 : + unscaledScrollX > (lastPageScroll + mMaxScrollX) / 2 ? + mMaxScrollX : + getScrollForPage(mNextPage); + + mScroller.setFinalX((int) (finalX * getScaleX())); // Ensure the scroll/snap doesn't happen too fast; int extraScrollDuration = OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION - mScroller.getDuration(); |