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

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

Merge "NumberPicker should not throw an exception if no enough values for wrapping."

parents 9f46b112 3f9c9eab
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26676,6 +26676,7 @@ package android.widget {
    method public void setOnValueChangedListener(android.widget.NumberPicker.OnValueChangeListener);
    method public void setValue(int);
    method public void setWrapSelectorWheel(boolean);
    field public static final int SELECTOR_WHEEL_ITEM_COUNT = 5; // 0x5
  }
  public static abstract interface NumberPicker.Formatter {
+13 −5
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ import com.android.internal.R;
@Widget
public class NumberPicker extends LinearLayout {

    /**
     * The number of items show in the selector wheel.
     */
    public static final int SELECTOR_WHEEL_ITEM_COUNT = 5;

    /**
     * The default update interval during long press.
     */
@@ -1137,14 +1142,17 @@ public class NumberPicker extends LinearLayout {
     * items shown on the selector wheel) the selector wheel wrapping is
     * enabled.
     * </p>
     *
     * <p>
     * <strong>Note:</strong> If the number of items, i.e. the range
     * ({@link #getMaxValue()} - {@link #getMinValue()}) is less than
     * {@link #SELECTOR_WHEEL_ITEM_COUNT}, the selector wheel will not
     * wrap. Hence, in such a case calling this method is a NOP.
     * </p>
     * @param wrapSelectorWheel Whether to wrap.
     */
    public void setWrapSelectorWheel(boolean wrapSelectorWheel) {
        if (wrapSelectorWheel && (mMaxValue - mMinValue) < mSelectorIndices.length) {
            throw new IllegalStateException("Range less than selector items count.");
        }
        if (wrapSelectorWheel != mWrapSelectorWheel) {
        final boolean wrappingAllowed = (mMaxValue - mMinValue) >= mSelectorIndices.length;
        if ((!wrapSelectorWheel || wrappingAllowed) && wrapSelectorWheel != mWrapSelectorWheel) {
            mWrapSelectorWheel = wrapSelectorWheel;
            updateIncrementAndDecrementButtonsVisibilityState();
        }