Merge "Fix full widgets picker fast scroll offset issue" into sc-dev
This commit is contained in:
@@ -106,6 +106,7 @@ public class RecyclerViewFastScroller extends View {
|
||||
// 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 class RecyclerViewFastScroller extends View {
|
||||
|
||||
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 @@ public class RecyclerViewFastScroller extends View {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ final class SearchAndRecommendationsScrollController implements
|
||||
* 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;
|
||||
|
||||
Reference in New Issue
Block a user