- This would happen when you scroll near the thumb and pass through the
area where the scrollbar was when the gesture started, and this CL
prevents gestures that move beyond a fixed distance from the original
touch position that is not already a fastscroll.
Bug:
23561678
Change-Id: I66226777671456a8919503dae4e92164ee10dd6d
private boolean mIsDragging;
private boolean mIsThumbDetached;
private boolean mCanThumbDetach;
private boolean mIsDragging;
private boolean mIsThumbDetached;
private boolean mCanThumbDetach;
+ private boolean mIgnoreDragGesture;
// This is the offset from the top of the scrollbar when the user first starts touching. To
// prevent jumping, this offset is applied as the user scrolls.
// This is the offset from the top of the scrollbar when the user first starts touching. To
// prevent jumping, this offset is applied as the user scrolls.
int y = (int) ev.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
int y = (int) ev.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
- if (isNearPoint(downX, downY)) {
+ if (isNearThumb(downX, downY)) {
mTouchOffset = downY - mThumbOffset.y;
}
break;
case MotionEvent.ACTION_MOVE:
mTouchOffset = downY - mThumbOffset.y;
}
break;
case MotionEvent.ACTION_MOVE:
- // Check if we should start scrolling
- if (!mIsDragging && isNearPoint(downX, downY) &&
+ // 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) &&
Math.abs(y - downY) > config.getScaledTouchSlop()) {
mRv.getParent().requestDisallowInterceptTouchEvent(true);
mIsDragging = true;
Math.abs(y - downY) > config.getScaledTouchSlop()) {
mRv.getParent().requestDisallowInterceptTouchEvent(true);
mIsDragging = true;
case MotionEvent.ACTION_CANCEL:
mTouchOffset = 0;
mLastTouchY = 0;
case MotionEvent.ACTION_CANCEL:
mTouchOffset = 0;
mLastTouchY = 0;
+ mIgnoreDragGesture = false;
if (mIsDragging) {
mIsDragging = false;
mPopup.animateVisibility(false);
if (mIsDragging) {
mIsDragging = false;
mPopup.animateVisibility(false);
/**
* Returns whether the specified points are near the scroll bar bounds.
*/
/**
* Returns whether the specified points are near the scroll bar bounds.
*/
- private boolean isNearPoint(int x, int y) {
+ private boolean isNearThumb(int x, int y) {
mTmpRect.set(mThumbOffset.x, mThumbOffset.y, mThumbOffset.x + mThumbWidth,
mThumbOffset.y + mThumbHeight);
mTmpRect.inset(mTouchInset, mTouchInset);
mTmpRect.set(mThumbOffset.x, mThumbOffset.y, mThumbOffset.x + mThumbWidth,
mThumbOffset.y + mThumbHeight);
mTmpRect.inset(mTouchInset, mTouchInset);