summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps
diff options
context:
space:
mode:
authorWinson <winsonc@google.com>2015-08-24 12:28:16 -0700
committerWinson <winsonc@google.com>2015-08-24 12:28:16 -0700
commit51a7d965443373e3a9f4fce1c0895669ed4110bd (patch)
tree07144662dc0d073e05d911da4aac29cf0e558b7c /src/com/android/launcher3/allapps
parentdd306188a6e8b4d00b8ef0ab402589c92802f04b (diff)
downloadandroid_packages_apps_Trebuchet-51a7d965443373e3a9f4fce1c0895669ed4110bd.tar.gz
android_packages_apps_Trebuchet-51a7d965443373e3a9f4fce1c0895669ed4110bd.tar.bz2
android_packages_apps_Trebuchet-51a7d965443373e3a9f4fce1c0895669ed4110bd.zip
Making the detached scrollbar catch up faster to the actual scroll position.
Bug: 20035978 Change-Id: I4f9780e1c5c1d10a7956ece729163544d79d72c3
Diffstat (limited to 'src/com/android/launcher3/allapps')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsRecyclerView.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 5ec8bb258..1cde7bfc0 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -267,8 +267,18 @@ public class AllAppsRecyclerView extends BaseRecyclerView
int diffScrollY = scrollBarY - thumbScrollY;
if (diffScrollY * dy > 0f) {
// User is scrolling in the same direction the thumb needs to catch up to the
- // current scroll position.
- thumbScrollY += dy < 0 ? Math.max(dy, diffScrollY) : Math.min(dy, diffScrollY);
+ // current scroll position. We do this by mapping the difference in movement
+ // from the original scroll bar position to the difference in movement necessary
+ // in the detached thumb position to ensure that both speed towards the same
+ // position at either end of the list.
+ if (dy < 0) {
+ int offset = (int) ((dy * thumbScrollY) / (float) scrollBarY);
+ thumbScrollY += Math.max(offset, diffScrollY);
+ } else {
+ int offset = (int) ((dy * (availableScrollBarHeight - thumbScrollY)) /
+ (float) (availableScrollBarHeight - scrollBarY));
+ thumbScrollY += Math.min(offset, diffScrollY);
+ }
thumbScrollY = Math.max(0, Math.min(availableScrollBarHeight, thumbScrollY));
mScrollbar.setThumbOffset(scrollBarX, thumbScrollY);
if (scrollBarY == thumbScrollY) {