Fix full widgets picker fast scroll offset issue

Even though there is no change in fast scroller offset, the recycler view
scroll Y may still be updated. Let's also notify a scroll change if
the recycler view scroll has changed when updating the fast scroller thumb
offset.

Test: In the full widgets picker, scroll up and down with the fast
      scroller. Then, scroll up and down in the recycler view. The top
      section is scrolled together with the recycler view smoothly.
Bug: 183721076
Change-Id: I009fc7e27c8a20505a60502405ebbf695b5a37f2
diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
index ae34257..9d0913a 100644
--- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java
+++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java
@@ -106,6 +106,7 @@
     // prevent jumping, this offset is applied as the user scrolls.
     protected int mTouchOffsetY;
     protected int mThumbOffsetY;
+    protected int mRvOffsetY;
 
     // Fast scroller popup
     private TextView mPopupView;
@@ -186,14 +187,18 @@
 
     public void setThumbOffsetY(int y) {
         if (mThumbOffsetY == y) {
+            int rvCurrentOffsetY = mRv.getCurrentScrollY();
+            if (mRvOffsetY != rvCurrentOffsetY) {
+                mRvOffsetY = mRv.getCurrentScrollY();
+                notifyScrollChanged();
+            }
             return;
         }
         updatePopupY(y);
         mThumbOffsetY = y;
         invalidate();
-        if (mOnFastScrollChangeListener != null) {
-            mOnFastScrollChangeListener.onThumbOffsetYChanged(mThumbOffsetY);
-        }
+        mRvOffsetY = mRv.getCurrentScrollY();
+        notifyScrollChanged();
     }
 
     public int getThumbOffsetY() {
@@ -422,13 +427,17 @@
         mOnFastScrollChangeListener = onFastScrollChangeListener;
     }
 
+    private void notifyScrollChanged() {
+        if (mOnFastScrollChangeListener != null) {
+            mOnFastScrollChangeListener.onScrollChanged();
+        }
+    }
+
     /**
      * A callback that is invoked when there is a scroll change in {@link RecyclerViewFastScroller}.
      */
     public interface OnFastScrollChangeListener {
-        /**
-         * Called when the thumb offset vertical position, in pixels, has changed to {@code y}.
-         */
-        void onThumbOffsetYChanged(int y);
+        /** Called when the recycler view scroll has changed. */
+        void onScrollChanged();
     }
 }
diff --git a/src/com/android/launcher3/widget/picker/SearchAndRecommendationsScrollController.java b/src/com/android/launcher3/widget/picker/SearchAndRecommendationsScrollController.java
index d09cb8a..2ca0d96 100644
--- a/src/com/android/launcher3/widget/picker/SearchAndRecommendationsScrollController.java
+++ b/src/com/android/launcher3/widget/picker/SearchAndRecommendationsScrollController.java
@@ -221,7 +221,7 @@
      * views (e.g. recycler views, tabs) upon scrolling.
      */
     @Override
-    public void onThumbOffsetYChanged(int unused) {
+    public void onScrollChanged() {
         // Always use the recycler view offset because fast scroller offset has a different scale.
         int recyclerViewYOffset = mCurrentRecyclerView.getCurrentScrollY();
         if (recyclerViewYOffset < 0) return;