summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
diff options
context:
space:
mode:
authorWinson <winsonc@google.com>2016-07-12 14:10:50 -0700
committerWinson Chung <winsonc@google.com>2016-07-13 01:04:56 +0000
commite8eaa9c94c5bfb9f103b486b24213e7dd86e8429 (patch)
tree8945f666232551837b5570d0f0c5b6857f9eb198 /src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
parentb029e9fd666263d3954387e3d96d67f377c23f8b (diff)
downloadandroid_packages_apps_Trebuchet-e8eaa9c94c5bfb9f103b486b24213e7dd86e8429.tar.gz
android_packages_apps_Trebuchet-e8eaa9c94c5bfb9f103b486b24213e7dd86e8429.tar.bz2
android_packages_apps_Trebuchet-e8eaa9c94c5bfb9f103b486b24213e7dd86e8429.zip
Ensuring that fast scrolling to predictions scrolls list to the top
- Fixes a long standing issue with fast-scrolling to the predicted apps not quite scrolling the list to the top of the screen. - Fixes an issue where we don’t scroll exactly to the fast scroll position due to rounding - Also fixes a small issue where the thumb would not update when the fast scroll popup was no longer showing, even while dragging. Bug: 30023608 Change-Id: I6b5080c6aea521ff03dca24317f0405c02725061
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java b/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
index 6d9094f78..76934af7d 100644
--- a/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
+++ b/src/com/android/launcher3/allapps/AllAppsFastScrollHelper.java
@@ -23,6 +23,7 @@ import com.android.launcher3.FastBitmapDrawable;
import com.android.launcher3.util.Thunk;
import java.util.HashSet;
+import java.util.List;
public class AllAppsFastScrollHelper implements AllAppsGridAdapter.BindViewCallback {
@@ -142,13 +143,22 @@ public class AllAppsFastScrollHelper implements AllAppsGridAdapter.BindViewCallb
}
// Calculate the full animation from the current scroll position to the final scroll
- // position, and then run the animation for the duration.
+ // position, and then run the animation for the duration. If we are scrolling to the
+ // first fast scroll section, then just scroll to the top of the list itself.
+ List<AlphabeticalAppsList.FastScrollSectionInfo> fastScrollSections =
+ mApps.getFastScrollerSections();
int newPosition = info.fastScrollToItem.position;
- int newScrollY = Math.min(availableScrollHeight, mRv.getCurrentScrollY(newPosition, 0));
+ int newScrollY = fastScrollSections.size() > 0 && fastScrollSections.get(0) == info
+ ? 0
+ : Math.min(availableScrollHeight, mRv.getCurrentScrollY(newPosition, 0));
int numFrames = mFastScrollFrames.length;
+ int deltaY = newScrollY - scrollY;
+ float ySign = Math.signum(deltaY);
+ int step = (int) (ySign * Math.ceil((float) Math.abs(deltaY) / numFrames));
for (int i = 0; i < numFrames; i++) {
// TODO(winsonc): We can interpolate this as well.
- mFastScrollFrames[i] = (newScrollY - scrollY) / numFrames;
+ mFastScrollFrames[i] = (int) (ySign * Math.min(Math.abs(step), Math.abs(deltaY)));
+ deltaY -= step;
}
mFastScrollFrameIndex = 0;
mRv.postOnAnimation(mSmoothSnapNextFrameRunnable);