WheelPicker icon indicating copy to clipboard operation
WheelPicker copied to clipboard

Bug in picker

Open spidfire opened this issue 8 years ago • 7 comments

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

ezgif-2357823105

spidfire avatar Dec 06 '16 14:12 spidfire

can confirm this bug. just scroll fast and then click to stop. do it couple times, it will stop in a mid-value

recoverrelax avatar Jan 04 '17 09:01 recoverrelax

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

spidfire avatar Jan 04 '17 10:01 spidfire

Do you know if the wheel can auto slide ? To have a button and to start scrolling by its own ?

ralucagurau avatar Jan 19 '17 08:01 ralucagurau

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
    }

johan-schoeman avatar Jan 29 '17 10:01 johan-schoeman

Removing this code in ActionUp of OnTouchEvent:

if (isClick) break;

seems to resolve the problem. I didn't found any side effects of this.

recoverrelax avatar Feb 10 '17 10:02 recoverrelax

Any news on this? Or does someone know how to fix this without modifying the WheelPicker.java?

danielRi avatar May 24 '17 13:05 danielRi

OK cool, this seems to be fixed in master, however not in 1.1.2 release version.

danielRi avatar May 26 '17 13:05 danielRi