Skip to content

Commit 234484a

Browse files
committed
NumberPicker getting stuck if scroll wheel not wrapable.
1. If the number picker was not wrapping the selector wheel it was incorrectly initializing the fling scroller and the error was proportional to the difference of the current value and the max size. As a result if the number picker gets stuck for a very long time. 2. The alpha of the selector wheel paint was not reset on every subsequent fling so if the wheel was fading out and a new fling is performed the selector wheel is dimmed during the fling, rather bright. bug:5728363 Change-Id: Ia90a6af86f162bda1b28f43f7ba7e4a9f5051b78
1 parent ca0a68c commit 234484a

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

core/java/android/widget/NumberPicker.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
776776
mBeginEditOnUpEvent = false;
777777
mAdjustScrollerOnUpEvent = true;
778778
if (mSelectorWheelState == SELECTOR_WHEEL_STATE_LARGE) {
779+
mSelectorWheelPaint.setAlpha(SELECTOR_WHEEL_BRIGHT_ALPHA);
779780
boolean scrollersFinished = mFlingScroller.isFinished()
780781
&& mAdjustScroller.isFinished();
781782
if (!scrollersFinished) {
@@ -1597,23 +1598,11 @@ private void onScrollStateChange(int scrollState) {
15971598
*/
15981599
private void fling(int velocityY) {
15991600
mPreviousScrollerY = 0;
1600-
Scroller flingScroller = mFlingScroller;
16011601

1602-
if (mWrapSelectorWheel) {
1603-
if (velocityY > 0) {
1604-
flingScroller.fling(0, 0, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
1605-
} else {
1606-
flingScroller.fling(0, Integer.MAX_VALUE, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
1607-
}
1602+
if (velocityY > 0) {
1603+
mFlingScroller.fling(0, 0, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
16081604
} else {
1609-
if (velocityY > 0) {
1610-
int maxY = mTextSize * (mValue - mMinValue);
1611-
flingScroller.fling(0, 0, 0, velocityY, 0, 0, 0, maxY);
1612-
} else {
1613-
int startY = mTextSize * (mMaxValue - mValue);
1614-
int maxY = startY;
1615-
flingScroller.fling(0, startY, 0, velocityY, 0, 0, 0, maxY);
1616-
}
1605+
mFlingScroller.fling(0, Integer.MAX_VALUE, 0, velocityY, 0, 0, 0, Integer.MAX_VALUE);
16171606
}
16181607

16191608
invalidate();

0 commit comments

Comments
 (0)