WheelPicker
WheelPicker copied to clipboard
Bug in picker
If you scroll hard and just stop the scroll it can get stuck between two values Is there a fix? I use 1.1.2
can confirm this bug. just scroll fast and then click to stop. do it couple times, it will stop in a mid-value
My current (dirty) solution is to see if the state is correct Written in Kotlin:
var currentState = 0
wheel.setOnWheelChangeListener(object: WheelPicker.OnWheelChangeListener {
override fun onWheelSelected(position: Int) {
}
override fun onWheelScrollStateChanged(state: Int) {
currentState = state
}
override fun onWheelScrolled(offset: Int) {
}
})
And if the currentState != WheelPicker.SCROLL_STATE_IDLE
the wheel is incorrect set
Do you know if the wheel can auto slide ? To have a button and to start scrolling by its own ?
See the last line of code in this part of method run() that I have added - seems to "take care" of the problem (and also the problem that I had whereby I could with a bit of care position the wheel between two entries in the wheel
``
@Override
public void run() {
if (mScroller.isFinished()) {
int position = (-mScrollOffsetY / mItemHeight + mSelectedItemPosition) % mData.size();
position = position < 0 ? position + mData.size() : position;
if (isDebug)
//BA.Log("TAG" + position + ":" + mData.get(position) + ":" + mScrollOffsetY);
mCurrentItemPosition = position;
if (null != mOnItemSelectedListener)
mOnItemSelectedListener.onItemSelected(this, mData.get(position), position);
//BA.Log("in run = " + mData.get(position));
if (null != mOnWheelChangeListener) {
//BA.Log("in run = " + mData.get(position));
mOnWheelChangeListener.onWheelSelected(position);
//BA.Log("in run" + position);
mOnWheelChangeListener.onWheelScrollStateChanged(SCROLL_STATE_IDLE);
}
setSelectedItemPosition(position); //ADDED THIS LINE
}
Removing this code in ActionUp of OnTouchEvent:
if (isClick) break;
seems to resolve the problem. I didn't found any side effects of this.
Any news on this? Or does someone know how to fix this without modifying the WheelPicker.java
?
OK cool, this seems to be fixed in master, however not in 1.1.2 release version.