From 646c236ad283c44e41747176fe1017d619b92d5a Mon Sep 17 00:00:00 2001 From: Winson Date: Thu, 3 Sep 2015 11:46:11 -0700 Subject: [PATCH] Disabling fast scroller when searching apps. - There is no meaningful order for the app search results since they are ranked. Bug: 23759082 Change-Id: I0aa4eea68136ea3ecef2a80b20ba7b0d46f0653b --- src/com/android/launcher3/BaseRecyclerView.java | 7 +++++++ .../android/launcher3/BaseRecyclerViewFastScrollBar.java | 3 ++- src/com/android/launcher3/allapps/AllAppsRecyclerView.java | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java index f0d8b3b3d2..9d713e338e 100644 --- a/src/com/android/launcher3/BaseRecyclerView.java +++ b/src/com/android/launcher3/BaseRecyclerView.java @@ -267,6 +267,13 @@ public abstract class BaseRecyclerView extends RecyclerView mScrollbar.setThumbOffset(scrollBarX, scrollBarY); } + /** + * Returns whether fast scrolling is supported in the current state. + */ + protected boolean supportsFastScrolling() { + return true; + } + /** * Maps the touch (from 0..1) to the adapter position that should be visible. *

Override in each subclass of this base class. diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java index fcee7e8ddf..32ea576671 100644 --- a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java +++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java @@ -189,7 +189,8 @@ public class BaseRecyclerViewFastScrollBar { // Check if we should start scrolling, but ignore this fastscroll gesture if we have // exceeded some fixed movement mIgnoreDragGesture |= Math.abs(y - downY) > config.getScaledPagingTouchSlop(); - if (!mIsDragging && !mIgnoreDragGesture && isNearThumb(downX, lastY) && + if (!mIsDragging && !mIgnoreDragGesture && mRv.supportsFastScrolling() && + isNearThumb(downX, lastY) && Math.abs(y - downY) > config.getScaledTouchSlop()) { mRv.getParent().requestDisallowInterceptTouchEvent(true); mIsDragging = true; diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 2f66e2cad6..10d10f11b3 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -431,6 +431,13 @@ public class AllAppsRecyclerView extends BaseRecyclerView } } + @Override + protected boolean supportsFastScrolling() { + // Only allow fast scrolling when the user is not searching, since the results are not + // grouped in a meaningful order + return !mApps.hasFilter(); + } + /** * Returns the scrollY for the given position in the adapter. */