Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48b428fb authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "NumberPicker getting stuck if scroll wheel not wrapable." into ics-mr1

parents 583fdf00 234484a9
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -776,6 +776,7 @@ public class NumberPicker extends LinearLayout {
                mBeginEditOnUpEvent = false;
                mAdjustScrollerOnUpEvent = true;
                if (mSelectorWheelState == SELECTOR_WHEEL_STATE_LARGE) {
                    mSelectorWheelPaint.setAlpha(SELECTOR_WHEEL_BRIGHT_ALPHA);
                    boolean scrollersFinished = mFlingScroller.isFinished()
                            && mAdjustScroller.isFinished();
                    if (!scrollersFinished) {
@@ -1597,23 +1598,11 @@ public class NumberPicker extends LinearLayout {
     */
    private void fling(int velocityY) {
        mPreviousScrollerY = 0;
        Scroller flingScroller = mFlingScroller;

        if (mWrapSelectorWheel) {
        if (velocityY > 0) {
                flingScroller.fling(0, 0, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
            } else {
                flingScroller.fling(0, Integer.MAX_VALUE, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
            }
            mFlingScroller.fling(0, 0, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
        } else {
            if (velocityY > 0) {
                int maxY = mTextSize * (mValue - mMinValue);
                flingScroller.fling(0, 0, 0, velocityY, 0, 0, 0, maxY);
            } else {
                int startY = mTextSize * (mMaxValue - mValue);
                int maxY = startY;
                flingScroller.fling(0, startY, 0, velocityY, 0, 0, 0, maxY);
            }
            mFlingScroller.fling(0, Integer.MAX_VALUE, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
        }

        invalidate();