Skip to content

Slow scroll cause that not selection on item, remain between two item #11

@HosseinDevPro

Description

@HosseinDevPro

When we scroll very slowly, it causes an error and didn't select any item and scroll position remain between two item and any item selection.
I debug this problem and find a solution, We need to refactor the ACTION_UP part in class WheelPicker as below:

MotionEvent.ACTION_UP -> { logd("### onTouchEventVertical: action > ACTION_UP") if (mIsDragging) { logd("onTouchEventVertical: is dragging > true") mIsDragging = false parent?.requestDisallowInterceptTouchEvent(false) mVelocityTracker?.computeCurrentVelocity(1000, mMaximumVelocity.toFloat()) val velocity = mVelocityTracker?.yVelocity?.toInt() if (Math.abs(velocity!!) > mMinimumVelocity) { logd("Velocity is bigger than minimum(" + mMinimumVelocity + "): " + velocity) mPreviousScrollerY = 0 mOverScroller?.fling( scrollX, scrollY, 0, velocity, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, (getItemHeight() * 0.7).toInt() ) invalidateOnAnimation() onScrollStateChange(OnScrollListener.SCROLL_STATE_FLING) } else { logd("Ooops.. >>> Velocity is smaller than minimum(" + mMinimumVelocity + "): " + velocity) val y = event.y.toInt() handlerClickVertical(y) } recyclerVelocityTracker() } else { logd("onTouchEventVertical: is dragging > false") //click event val y = event.y.toInt() handlerClickVertical(y) } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions