Skip to content

Commit e9812ba

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Revert "NumberPicker should adjust min and max when displayed values are set." (a.k.a. Santa is back)" into jb-mr1-dev
2 parents aaec726 + 7018cfd commit e9812ba

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

core/java/android/widget/NumberPicker.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,12 @@ public int getMinValue() {
12841284
/**
12851285
* Sets the min value of the picker.
12861286
*
1287-
* @param minValue The min value.
1287+
* @param minValue The min value inclusive.
1288+
*
1289+
* <strong>Note:</strong> The length of the displayed values array
1290+
* set via {@link #setDisplayedValues(String[])} must be equal to the
1291+
* range of selectable numbers which is equal to
1292+
* {@link #getMaxValue()} - {@link #getMinValue()} + 1.
12881293
*/
12891294
public void setMinValue(int minValue) {
12901295
if (mMinValue == minValue) {
@@ -1317,7 +1322,12 @@ public int getMaxValue() {
13171322
/**
13181323
* Sets the max value of the picker.
13191324
*
1320-
* @param maxValue The max value.
1325+
* @param maxValue The max value inclusive.
1326+
*
1327+
* <strong>Note:</strong> The length of the displayed values array
1328+
* set via {@link #setDisplayedValues(String[])} must be equal to the
1329+
* range of selectable numbers which is equal to
1330+
* {@link #getMaxValue()} - {@link #getMinValue()} + 1.
13211331
*/
13221332
public void setMaxValue(int maxValue) {
13231333
if (mMaxValue == maxValue) {
@@ -1351,6 +1361,10 @@ public String[] getDisplayedValues() {
13511361
* Sets the values to be displayed.
13521362
*
13531363
* @param displayedValues The displayed values.
1364+
*
1365+
* <strong>Note:</strong> The length of the displayed values array
1366+
* must be equal to the range of selectable numbers which is equal to
1367+
* {@link #getMaxValue()} - {@link #getMinValue()} + 1.
13541368
*/
13551369
public void setDisplayedValues(String[] displayedValues) {
13561370
if (mDisplayedValues == displayedValues) {
@@ -1361,14 +1375,6 @@ public void setDisplayedValues(String[] displayedValues) {
13611375
// Allow text entry rather than strictly numeric entry.
13621376
mInputText.setRawInputType(InputType.TYPE_CLASS_TEXT
13631377
| InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
1364-
// Make sure the min, max, respect the size of the displayed
1365-
// values. This will take care of the current value as well.
1366-
if (getMinValue() >= displayedValues.length) {
1367-
setMinValue(0);
1368-
}
1369-
if (getMaxValue() >= displayedValues.length) {
1370-
setMaxValue(displayedValues.length - 1);
1371-
}
13721378
} else {
13731379
mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
13741380
}

0 commit comments

Comments
 (0)