-
Notifications
You must be signed in to change notification settings - Fork 27
Description
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) } }