Align rounded corner of fastscroller popup with the top of the thumb.

Bug: 63852509
Change-Id: I90b6d3e87206a53cfb4c8025a8e5f9597cf73898
This commit is contained in:
Jon Miranda
2018-09-26 13:16:24 -07:00
parent a4483361ff
commit b0edaeb268

View File

@@ -175,6 +175,7 @@ public class RecyclerViewFastScroller extends View {
if (mThumbOffsetY == y) {
return;
}
updatePopupY((int) y);
mThumbOffsetY = y;
invalidate();
}
@@ -281,7 +282,6 @@ public class RecyclerViewFastScroller extends View {
mPopupView.setText(sectionName);
}
animatePopupVisibility(!sectionName.isEmpty());
updatePopupY(lastY);
mLastTouchY = boundedY;
setThumbOffsetY((int) mLastTouchY);
}
@@ -299,11 +299,14 @@ public class RecyclerViewFastScroller extends View {
canvas.translate(0, mThumbOffsetY);
halfW += mThumbPadding;
float r = mWidth + mThumbPadding + mThumbPadding;
float r = getScrollThumbRadius();
canvas.drawRoundRect(-halfW, 0, halfW, mThumbHeight, r, r, mThumbPaint);
canvas.restoreToCount(saveCount);
}
private float getScrollThumbRadius() {
return mWidth + mThumbPadding + mThumbPadding;
}
/**
* Animates the width of the scrollbar.
@@ -352,11 +355,15 @@ public class RecyclerViewFastScroller extends View {
}
private void updatePopupY(int lastTouchY) {
if (!mPopupVisible) {
return;
}
int height = mPopupView.getHeight();
float top = lastTouchY - (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * height)
+ mRv.getScrollBarTop();
top = Utilities.boundToRange(top,
mMaxWidth, mRv.getScrollbarTrackHeight() - mMaxWidth - height);
// Aligns the rounded corner of the pop up with the top of the thumb.
float top = mRv.getScrollBarTop() + lastTouchY + (getScrollThumbRadius() / 2f)
- (height / 2f);
top = Utilities.boundToRange(top, 0,
getTop() + mRv.getScrollBarTop() + mRv.getScrollbarTrackHeight() - height);
mPopupView.setTranslationY(top);
}