Loading api/current.xml +319 −0 Original line number Diff line number Diff line Loading @@ -239929,6 +239929,325 @@ </parameter> </method> </interface> <class name="NumberPicker" extends="android.widget.LinearLayout" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <constructor name="NumberPicker" type="android.widget.NumberPicker" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> </constructor> <constructor name="NumberPicker" type="android.widget.NumberPicker" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <constructor name="NumberPicker" type="android.widget.NumberPicker" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> <parameter name="defStyle" type="int"> </parameter> </constructor> <method name="getCurrent" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getRangeEnd" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getRangeStart" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="setCurrent" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="current" type="int"> </parameter> </method> <method name="setFormatter" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="formatter" type="android.widget.NumberPicker.Formatter"> </parameter> </method> <method name="setOnChangeListener" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="onChangeListener" type="android.widget.NumberPicker.OnChangeListener"> </parameter> </method> <method name="setOnLongPressUpdateInterval" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="intervalMillis" type="long"> </parameter> </method> <method name="setOnScrollListener" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="onScrollListener" type="android.widget.NumberPicker.OnScrollListener"> </parameter> </method> <method name="setRange" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="start" type="int"> </parameter> <parameter name="end" type="int"> </parameter> </method> <method name="setRange" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="start" type="int"> </parameter> <parameter name="end" type="int"> </parameter> <parameter name="displayedValues" type="java.lang.String[]"> </parameter> </method> <method name="setRange" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="start" type="int"> </parameter> <parameter name="end" type="int"> </parameter> <parameter name="displayedValues" type="java.lang.String[]"> </parameter> <parameter name="wrapSelectorWheel" type="boolean"> </parameter> </method> <method name="setWrapSelectorWheel" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="wrapSelector" type="boolean"> </parameter> </method> <field name="TWO_DIGIT_FORMATTER" type="android.widget.NumberPicker.Formatter" transient="false" volatile="false" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </class> <interface name="NumberPicker.Formatter" abstract="true" static="true" final="false" deprecated="not deprecated" visibility="public" > <method name="toString" return="java.lang.String" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="value" type="int"> </parameter> </method> </interface> <interface name="NumberPicker.OnChangeListener" abstract="true" static="true" final="false" deprecated="not deprecated" visibility="public" > <method name="onChange" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="picker" type="android.widget.NumberPicker"> </parameter> <parameter name="oldVal" type="int"> </parameter> <parameter name="newVal" type="int"> </parameter> </method> </interface> <interface name="NumberPicker.OnScrollListener" abstract="true" static="true" final="false" deprecated="not deprecated" visibility="public" > <method name="onScrollStateChange" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="view" type="android.widget.NumberPicker"> </parameter> <parameter name="scrollState" type="int"> </parameter> </method> <field name="SCROLL_STATE_FLING" type="int" transient="false" volatile="false" value="2" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCROLL_STATE_IDLE" type="int" transient="false" volatile="false" value="0" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCROLL_STATE_TOUCH_SCROLL" type="int" transient="false" volatile="false" value="1" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </interface> <class name="OverScroller" extends="java.lang.Object" abstract="false" core/java/android/widget/DatePicker.java +6 −6 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.SparseArray; import android.view.LayoutInflater; import android.widget.NumberPicker.OnChangedListener; import android.widget.NumberPicker.OnChangeListener; import java.text.SimpleDateFormat; import java.util.Calendar; Loading Loading @@ -97,8 +97,8 @@ public class DatePicker extends FrameLayout { .getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.date_picker, this, true); OnChangedListener onChangeListener = new OnChangedListener() { public void onChanged(NumberPicker picker, int oldVal, int newVal) { OnChangeListener onChangeListener = new OnChangeListener() { public void onChange(NumberPicker picker, int oldVal, int newVal) { notifyDateChanged(); updateMiniMonth(); } Loading @@ -107,18 +107,18 @@ public class DatePicker extends FrameLayout { // day mDayPicker = (NumberPicker) findViewById(R.id.day); mDayPicker.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER); mDayPicker.setSpeed(100); mDayPicker.setOnLongPressUpdateInterval(100); mDayPicker.setOnChangeListener(onChangeListener); // month mMonthPicker = (NumberPicker) findViewById(R.id.month); mMonthPicker.setRange(0, mNumberOfMonths - 1, getShortMonths()); mMonthPicker.setSpeed(200); mMonthPicker.setOnLongPressUpdateInterval(200); mMonthPicker.setOnChangeListener(onChangeListener); // year mYearPicker = (NumberPicker) findViewById(R.id.year); mYearPicker.setSpeed(100); mYearPicker.setOnLongPressUpdateInterval(100); mYearPicker.setOnChangeListener(onChangeListener); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePicker); int mStartYear = a.getInt(R.styleable.DatePicker_startYear, DEFAULT_START_YEAR); Loading core/java/android/widget/NumberPicker.java +104 −61 Original line number Diff line number Diff line Loading @@ -50,10 +50,18 @@ import android.view.animation.OvershootInterpolator; import android.view.inputmethod.InputMethodManager; /** * A view for selecting a number For a dialog using this view, see * {@link android.app.TimePickerDialog}. * * @hide * A widget that enables the user to select a number form a predefined range. * The widget presents an input filed and up and down buttons for selecting the * current value. Pressing/long pressing the up and down buttons increments and * decrements the current value respectively. Touching the input filed shows a * scroll wheel, tapping on which while shown and not moving allows direct edit * of the current value. Sliding motions up or down hide the buttons and the * input filed, show the scroll wheel, and rotate the latter. Flinging is * also supported. The widget enables mapping from positions to strings such * that instead the position index the corresponding string is displayed. * <p> * For an example of using this widget, see {@link android.widget.TimePicker}. * </p> */ @Widget public class NumberPicker extends LinearLayout { Loading Loading @@ -166,7 +174,7 @@ public class NumberPicker extends LinearLayout { /** * Listener to be notified upon current value change. */ private OnChangedListener mOnChangedListener; private OnChangeListener mOnChangeListener; /** * Listener to be notified upon scroll state change. Loading @@ -181,7 +189,7 @@ public class NumberPicker extends LinearLayout { /** * The speed for updating the value form long press. */ private long mLongPressUpdateSpeed = 300; private long mLongPressUpdateInterval = 300; /** * Cache for the string representation of selector indices. Loading Loading @@ -320,13 +328,15 @@ public class NumberPicker extends LinearLayout { /** * The callback interface used to indicate the number value has changed. */ public interface OnChangedListener { public interface OnChangeListener { /** * Called upon a change of the current value. * * @param picker The NumberPicker associated with this listener. * @param oldVal The previous value. * @param newVal The new value. */ void onChanged(NumberPicker picker, int oldVal, int newVal); void onChange(NumberPicker picker, int oldVal, int newVal); } /** Loading Loading @@ -356,18 +366,34 @@ public class NumberPicker extends LinearLayout { * @param scrollState The current scroll state. One of {@link #SCROLL_STATE_IDLE}, * {@link #SCROLL_STATE_TOUCH_SCROLL} or {@link #SCROLL_STATE_IDLE}. */ public void onScrollStateChanged(NumberPicker view, int scrollState); public void onScrollStateChange(NumberPicker view, int scrollState); } /** * Interface used to format the number into a string for presentation * Interface used to format the number into a string for presentation. */ public interface Formatter { String toString(int value); /** * Formats a string representation of the current index. * * @param value The currently selected value. * @return A formatted string representation. */ public String toString(int value); } /** * Create a new number picker * Create a new number picker. * * @param context The application environment. */ public NumberPicker(Context context) { this(context, null); } /** * Create a new number picker. * * @param context The application environment. * @param attrs A collection of attributes. Loading Loading @@ -735,17 +761,22 @@ public class NumberPicker extends LinearLayout { } } @Override public int getSolidColor() { return mSolidColor; } /** * Set the callback that indicates the number has been adjusted by the user. * Sets the listener to be notified on change of the current value. * * @param onChangeListener the callback, should not be null. * @param onChangeListener The listener. */ public void setOnChangeListener(OnChangedListener onChangeListener) { mOnChangedListener = onChangeListener; public void setOnChangeListener(OnChangeListener onChangeListener) { mOnChangeListener = onChangeListener; } /** * Set the callback that in notified for scroll state changes. * Set listener to be notified for scroll state changes. * * @param onScrollListener the callback, should not be null. */ Loading @@ -754,10 +785,16 @@ public class NumberPicker extends LinearLayout { } /** * Set the formatter that will be used to format the number for presentation * Set the formatter to be used for formatting the current value. * <p> * Note: If you have provided alternative values for the selected positons * this formatter is never invoked. * </p> * * @param formatter the formatter object. If formatter is null, * String.valueOf() will be used * String.valueOf() will be used. * * @see #setRange(int, int, String[]) */ public void setFormatter(Formatter formatter) { mFormatter = formatter; Loading @@ -777,11 +814,11 @@ public class NumberPicker extends LinearLayout { /** * Set the range of numbers allowed for the number picker. The current value * will be automatically set to the start. Also provide a mapping for values * used to display to the user. * used to display to the user instead of the numbers in the range. * * @param start the start of the range (inclusive) * @param end the end of the range (inclusive) * @param displayedValues the values displayed to the user. * @param start The start of the range (inclusive). * @param end The end of the range (inclusive). * @param displayedValues The values displayed to the user. */ public void setRange(int start, int end, String[] displayedValues) { boolean wrapSelector = (end - start) >= mSelectorIndices.length; Loading @@ -792,12 +829,20 @@ public class NumberPicker extends LinearLayout { * Set the range of numbers allowed for the number picker. The current value * will be automatically set to the start. Also provide a mapping for values * used to display to the user. * <p> * Note: The <code>wrapSelectorWheel</code> argument is ignored if the range * (difference between <code>start</code> and <code>end</code>) us less than * five since this is the number of values shown by the selector wheel. * </p> * * @param start the start of the range (inclusive) * @param end the end of the range (inclusive) * @param displayedValues the values displayed to the user. * @param wrapSelectorWheel Whether to wrap the selector wheel. * * @see #setWrapSelectorWheel(boolean) */ public void setRange(int start, int end, String[] displayedValues, boolean wrapSelector) { public void setRange(int start, int end, String[] displayedValues, boolean wrapSelectorWheel) { if (start < 0 || end < 0) { throw new IllegalArgumentException("start and end must be > 0"); } Loading @@ -807,7 +852,7 @@ public class NumberPicker extends LinearLayout { mEnd = end; mCurrent = start; setWrapSelector(wrapSelector); setWrapSelectorWheel(wrapSelectorWheel); updateInputTextView(); if (displayedValues != null) { Loading @@ -826,8 +871,9 @@ public class NumberPicker extends LinearLayout { * Set the current value for the number picker. * * @param current the current value the start of the range (inclusive) * * @throws IllegalArgumentException when current is not within the range of * of the number picker * of the number picker. */ public void setCurrent(int current) { if (current < mStart || current > mEnd) { Loading @@ -839,12 +885,14 @@ public class NumberPicker extends LinearLayout { } /** * Sets whether the selector shown during flinging/scrolling should wrap * around the beginning and end values. * Sets whether the selector wheel shown during flinging/scrolling should wrap * around the beginning and end values. By default if the range is more than * five (the number of items shown on the selector wheel) the selector wheel * wrapping is enabled. * * @param wrapSelector Whether to wrap. */ public void setWrapSelector(boolean wrapSelector) { public void setWrapSelectorWheel(boolean wrapSelector) { if (wrapSelector && (mEnd - mStart) < mSelectorIndices.length) { throw new IllegalStateException("Range less than selector items count."); } Loading @@ -856,18 +904,18 @@ public class NumberPicker extends LinearLayout { } /** * Sets the speed at which the numbers will scroll when the +/- buttons are * longpressed * Sets the speed at which the numbers be incremented and decremented when * the up and down buttons are long pressed respectively. * * @param speed The speed (in milliseconds) at which the numbers will scroll * default 300ms * @param intervalMillis The speed (in milliseconds) at which the numbers * will be incremented and decremented (default 300ms). */ public void setSpeed(long speed) { mLongPressUpdateSpeed = speed; public void setOnLongPressUpdateInterval(long intervalMillis) { mLongPressUpdateInterval = intervalMillis; } /** * Returns the current value of the NumberPicker * Returns the current value of the NumberPicker. * * @return the current value. */ Loading @@ -875,9 +923,22 @@ public class NumberPicker extends LinearLayout { return mCurrent; } @Override public int getSolidColor() { return mSolidColor; /** * Returns the range lower value of the NumberPicker. * * @return The lower number of the range. */ public int getRangeStart() { return mStart; } /** * Returns the range end value of the NumberPicker. * * @return The upper number of the range. */ public int getRangeEnd() { return mEnd; } @Override Loading Loading @@ -949,24 +1010,6 @@ public class NumberPicker extends LinearLayout { } } /** * Returns the upper value of the range of the NumberPicker * * @return the uppper number of the range. */ protected int getEndRange() { return mEnd; } /** * Returns the lower value of the range of the NumberPicker * * @return the lower number of the range. */ protected int getBeginRange() { return mStart; } /** * Sets the current value of this NumberPicker, and sets mPrevious to the * previous value. If current is greater than mEnd less than mStart, the Loading Loading @@ -1038,7 +1081,7 @@ public class NumberPicker extends LinearLayout { private void tryNotifyScrollListener(int scrollState) { if (mOnScrollListener != null && mScrollState != scrollState) { mScrollState = scrollState; mOnScrollListener.onScrollStateChanged(this, scrollState); mOnScrollListener.onScrollStateChange(this, scrollState); } } Loading Loading @@ -1238,8 +1281,8 @@ public class NumberPicker extends LinearLayout { * NumberPicker. */ private void notifyChange(int previous, int current) { if (mOnChangedListener != null) { mOnChangedListener.onChanged(this, previous, mCurrent); if (mOnChangeListener != null) { mOnChangeListener.onChange(this, previous, mCurrent); } } Loading Loading @@ -1439,7 +1482,7 @@ public class NumberPicker extends LinearLayout { public void run() { changeCurrent(mCurrent + mUpdateStep); postDelayed(this, mLongPressUpdateSpeed); postDelayed(this, mLongPressUpdateInterval); } } } core/java/android/widget/TimePicker.java +8 −8 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.os.Parcelable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.NumberPicker.OnChangedListener; import android.widget.NumberPicker.OnChangeListener; import java.text.DateFormatSymbols; import java.util.Calendar; Loading Loading @@ -110,8 +110,8 @@ public class TimePicker extends FrameLayout { // hour mHourPicker = (NumberPicker) findViewById(R.id.hour); mHourPicker.setOnChangeListener(new NumberPicker.OnChangedListener() { public void onChanged(NumberPicker spinner, int oldVal, int newVal) { mHourPicker.setOnChangeListener(new NumberPicker.OnChangeListener() { public void onChange(NumberPicker spinner, int oldVal, int newVal) { mCurrentHour = newVal; if (!mIs24HourView) { // adjust from [1-12] to [0-11] internally, with the times Loading @@ -135,10 +135,10 @@ public class TimePicker extends FrameLayout { // digits of minute mMinutePicker = (NumberPicker) findViewById(R.id.minute); mMinutePicker.setRange(0, 59); mMinutePicker.setSpeed(100); mMinutePicker.setOnLongPressUpdateInterval(100); mMinutePicker.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER); mMinutePicker.setOnChangeListener(new NumberPicker.OnChangedListener() { public void onChanged(NumberPicker spinner, int oldVal, int newVal) { mMinutePicker.setOnChangeListener(new NumberPicker.OnChangeListener() { public void onChange(NumberPicker spinner, int oldVal, int newVal) { mCurrentMinute = newVal; onTimeChanged(); } Loading @@ -146,8 +146,8 @@ public class TimePicker extends FrameLayout { // am/pm mAmPmPicker = (NumberPicker) findViewById(R.id.amPm); mAmPmPicker.setOnChangeListener(new OnChangedListener() { public void onChanged(NumberPicker picker, int oldVal, int newVal) { mAmPmPicker.setOnChangeListener(new OnChangeListener() { public void onChange(NumberPicker picker, int oldVal, int newVal) { picker.requestFocus(); if (mIsAm) { // Currently AM switching to PM Loading Loading
api/current.xml +319 −0 Original line number Diff line number Diff line Loading @@ -239929,6 +239929,325 @@ </parameter> </method> </interface> <class name="NumberPicker" extends="android.widget.LinearLayout" abstract="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <constructor name="NumberPicker" type="android.widget.NumberPicker" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> </constructor> <constructor name="NumberPicker" type="android.widget.NumberPicker" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> <constructor name="NumberPicker" type="android.widget.NumberPicker" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="context" type="android.content.Context"> </parameter> <parameter name="attrs" type="android.util.AttributeSet"> </parameter> <parameter name="defStyle" type="int"> </parameter> </constructor> <method name="getCurrent" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getRangeEnd" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="getRangeStart" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > </method> <method name="setCurrent" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="current" type="int"> </parameter> </method> <method name="setFormatter" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="formatter" type="android.widget.NumberPicker.Formatter"> </parameter> </method> <method name="setOnChangeListener" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="onChangeListener" type="android.widget.NumberPicker.OnChangeListener"> </parameter> </method> <method name="setOnLongPressUpdateInterval" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="intervalMillis" type="long"> </parameter> </method> <method name="setOnScrollListener" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="onScrollListener" type="android.widget.NumberPicker.OnScrollListener"> </parameter> </method> <method name="setRange" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="start" type="int"> </parameter> <parameter name="end" type="int"> </parameter> </method> <method name="setRange" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="start" type="int"> </parameter> <parameter name="end" type="int"> </parameter> <parameter name="displayedValues" type="java.lang.String[]"> </parameter> </method> <method name="setRange" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="start" type="int"> </parameter> <parameter name="end" type="int"> </parameter> <parameter name="displayedValues" type="java.lang.String[]"> </parameter> <parameter name="wrapSelectorWheel" type="boolean"> </parameter> </method> <method name="setWrapSelectorWheel" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="wrapSelector" type="boolean"> </parameter> </method> <field name="TWO_DIGIT_FORMATTER" type="android.widget.NumberPicker.Formatter" transient="false" volatile="false" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </class> <interface name="NumberPicker.Formatter" abstract="true" static="true" final="false" deprecated="not deprecated" visibility="public" > <method name="toString" return="java.lang.String" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="value" type="int"> </parameter> </method> </interface> <interface name="NumberPicker.OnChangeListener" abstract="true" static="true" final="false" deprecated="not deprecated" visibility="public" > <method name="onChange" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="picker" type="android.widget.NumberPicker"> </parameter> <parameter name="oldVal" type="int"> </parameter> <parameter name="newVal" type="int"> </parameter> </method> </interface> <interface name="NumberPicker.OnScrollListener" abstract="true" static="true" final="false" deprecated="not deprecated" visibility="public" > <method name="onScrollStateChange" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="view" type="android.widget.NumberPicker"> </parameter> <parameter name="scrollState" type="int"> </parameter> </method> <field name="SCROLL_STATE_FLING" type="int" transient="false" volatile="false" value="2" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCROLL_STATE_IDLE" type="int" transient="false" volatile="false" value="0" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="SCROLL_STATE_TOUCH_SCROLL" type="int" transient="false" volatile="false" value="1" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> </interface> <class name="OverScroller" extends="java.lang.Object" abstract="false"
core/java/android/widget/DatePicker.java +6 −6 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.SparseArray; import android.view.LayoutInflater; import android.widget.NumberPicker.OnChangedListener; import android.widget.NumberPicker.OnChangeListener; import java.text.SimpleDateFormat; import java.util.Calendar; Loading Loading @@ -97,8 +97,8 @@ public class DatePicker extends FrameLayout { .getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.date_picker, this, true); OnChangedListener onChangeListener = new OnChangedListener() { public void onChanged(NumberPicker picker, int oldVal, int newVal) { OnChangeListener onChangeListener = new OnChangeListener() { public void onChange(NumberPicker picker, int oldVal, int newVal) { notifyDateChanged(); updateMiniMonth(); } Loading @@ -107,18 +107,18 @@ public class DatePicker extends FrameLayout { // day mDayPicker = (NumberPicker) findViewById(R.id.day); mDayPicker.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER); mDayPicker.setSpeed(100); mDayPicker.setOnLongPressUpdateInterval(100); mDayPicker.setOnChangeListener(onChangeListener); // month mMonthPicker = (NumberPicker) findViewById(R.id.month); mMonthPicker.setRange(0, mNumberOfMonths - 1, getShortMonths()); mMonthPicker.setSpeed(200); mMonthPicker.setOnLongPressUpdateInterval(200); mMonthPicker.setOnChangeListener(onChangeListener); // year mYearPicker = (NumberPicker) findViewById(R.id.year); mYearPicker.setSpeed(100); mYearPicker.setOnLongPressUpdateInterval(100); mYearPicker.setOnChangeListener(onChangeListener); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePicker); int mStartYear = a.getInt(R.styleable.DatePicker_startYear, DEFAULT_START_YEAR); Loading
core/java/android/widget/NumberPicker.java +104 −61 Original line number Diff line number Diff line Loading @@ -50,10 +50,18 @@ import android.view.animation.OvershootInterpolator; import android.view.inputmethod.InputMethodManager; /** * A view for selecting a number For a dialog using this view, see * {@link android.app.TimePickerDialog}. * * @hide * A widget that enables the user to select a number form a predefined range. * The widget presents an input filed and up and down buttons for selecting the * current value. Pressing/long pressing the up and down buttons increments and * decrements the current value respectively. Touching the input filed shows a * scroll wheel, tapping on which while shown and not moving allows direct edit * of the current value. Sliding motions up or down hide the buttons and the * input filed, show the scroll wheel, and rotate the latter. Flinging is * also supported. The widget enables mapping from positions to strings such * that instead the position index the corresponding string is displayed. * <p> * For an example of using this widget, see {@link android.widget.TimePicker}. * </p> */ @Widget public class NumberPicker extends LinearLayout { Loading Loading @@ -166,7 +174,7 @@ public class NumberPicker extends LinearLayout { /** * Listener to be notified upon current value change. */ private OnChangedListener mOnChangedListener; private OnChangeListener mOnChangeListener; /** * Listener to be notified upon scroll state change. Loading @@ -181,7 +189,7 @@ public class NumberPicker extends LinearLayout { /** * The speed for updating the value form long press. */ private long mLongPressUpdateSpeed = 300; private long mLongPressUpdateInterval = 300; /** * Cache for the string representation of selector indices. Loading Loading @@ -320,13 +328,15 @@ public class NumberPicker extends LinearLayout { /** * The callback interface used to indicate the number value has changed. */ public interface OnChangedListener { public interface OnChangeListener { /** * Called upon a change of the current value. * * @param picker The NumberPicker associated with this listener. * @param oldVal The previous value. * @param newVal The new value. */ void onChanged(NumberPicker picker, int oldVal, int newVal); void onChange(NumberPicker picker, int oldVal, int newVal); } /** Loading Loading @@ -356,18 +366,34 @@ public class NumberPicker extends LinearLayout { * @param scrollState The current scroll state. One of {@link #SCROLL_STATE_IDLE}, * {@link #SCROLL_STATE_TOUCH_SCROLL} or {@link #SCROLL_STATE_IDLE}. */ public void onScrollStateChanged(NumberPicker view, int scrollState); public void onScrollStateChange(NumberPicker view, int scrollState); } /** * Interface used to format the number into a string for presentation * Interface used to format the number into a string for presentation. */ public interface Formatter { String toString(int value); /** * Formats a string representation of the current index. * * @param value The currently selected value. * @return A formatted string representation. */ public String toString(int value); } /** * Create a new number picker * Create a new number picker. * * @param context The application environment. */ public NumberPicker(Context context) { this(context, null); } /** * Create a new number picker. * * @param context The application environment. * @param attrs A collection of attributes. Loading Loading @@ -735,17 +761,22 @@ public class NumberPicker extends LinearLayout { } } @Override public int getSolidColor() { return mSolidColor; } /** * Set the callback that indicates the number has been adjusted by the user. * Sets the listener to be notified on change of the current value. * * @param onChangeListener the callback, should not be null. * @param onChangeListener The listener. */ public void setOnChangeListener(OnChangedListener onChangeListener) { mOnChangedListener = onChangeListener; public void setOnChangeListener(OnChangeListener onChangeListener) { mOnChangeListener = onChangeListener; } /** * Set the callback that in notified for scroll state changes. * Set listener to be notified for scroll state changes. * * @param onScrollListener the callback, should not be null. */ Loading @@ -754,10 +785,16 @@ public class NumberPicker extends LinearLayout { } /** * Set the formatter that will be used to format the number for presentation * Set the formatter to be used for formatting the current value. * <p> * Note: If you have provided alternative values for the selected positons * this formatter is never invoked. * </p> * * @param formatter the formatter object. If formatter is null, * String.valueOf() will be used * String.valueOf() will be used. * * @see #setRange(int, int, String[]) */ public void setFormatter(Formatter formatter) { mFormatter = formatter; Loading @@ -777,11 +814,11 @@ public class NumberPicker extends LinearLayout { /** * Set the range of numbers allowed for the number picker. The current value * will be automatically set to the start. Also provide a mapping for values * used to display to the user. * used to display to the user instead of the numbers in the range. * * @param start the start of the range (inclusive) * @param end the end of the range (inclusive) * @param displayedValues the values displayed to the user. * @param start The start of the range (inclusive). * @param end The end of the range (inclusive). * @param displayedValues The values displayed to the user. */ public void setRange(int start, int end, String[] displayedValues) { boolean wrapSelector = (end - start) >= mSelectorIndices.length; Loading @@ -792,12 +829,20 @@ public class NumberPicker extends LinearLayout { * Set the range of numbers allowed for the number picker. The current value * will be automatically set to the start. Also provide a mapping for values * used to display to the user. * <p> * Note: The <code>wrapSelectorWheel</code> argument is ignored if the range * (difference between <code>start</code> and <code>end</code>) us less than * five since this is the number of values shown by the selector wheel. * </p> * * @param start the start of the range (inclusive) * @param end the end of the range (inclusive) * @param displayedValues the values displayed to the user. * @param wrapSelectorWheel Whether to wrap the selector wheel. * * @see #setWrapSelectorWheel(boolean) */ public void setRange(int start, int end, String[] displayedValues, boolean wrapSelector) { public void setRange(int start, int end, String[] displayedValues, boolean wrapSelectorWheel) { if (start < 0 || end < 0) { throw new IllegalArgumentException("start and end must be > 0"); } Loading @@ -807,7 +852,7 @@ public class NumberPicker extends LinearLayout { mEnd = end; mCurrent = start; setWrapSelector(wrapSelector); setWrapSelectorWheel(wrapSelectorWheel); updateInputTextView(); if (displayedValues != null) { Loading @@ -826,8 +871,9 @@ public class NumberPicker extends LinearLayout { * Set the current value for the number picker. * * @param current the current value the start of the range (inclusive) * * @throws IllegalArgumentException when current is not within the range of * of the number picker * of the number picker. */ public void setCurrent(int current) { if (current < mStart || current > mEnd) { Loading @@ -839,12 +885,14 @@ public class NumberPicker extends LinearLayout { } /** * Sets whether the selector shown during flinging/scrolling should wrap * around the beginning and end values. * Sets whether the selector wheel shown during flinging/scrolling should wrap * around the beginning and end values. By default if the range is more than * five (the number of items shown on the selector wheel) the selector wheel * wrapping is enabled. * * @param wrapSelector Whether to wrap. */ public void setWrapSelector(boolean wrapSelector) { public void setWrapSelectorWheel(boolean wrapSelector) { if (wrapSelector && (mEnd - mStart) < mSelectorIndices.length) { throw new IllegalStateException("Range less than selector items count."); } Loading @@ -856,18 +904,18 @@ public class NumberPicker extends LinearLayout { } /** * Sets the speed at which the numbers will scroll when the +/- buttons are * longpressed * Sets the speed at which the numbers be incremented and decremented when * the up and down buttons are long pressed respectively. * * @param speed The speed (in milliseconds) at which the numbers will scroll * default 300ms * @param intervalMillis The speed (in milliseconds) at which the numbers * will be incremented and decremented (default 300ms). */ public void setSpeed(long speed) { mLongPressUpdateSpeed = speed; public void setOnLongPressUpdateInterval(long intervalMillis) { mLongPressUpdateInterval = intervalMillis; } /** * Returns the current value of the NumberPicker * Returns the current value of the NumberPicker. * * @return the current value. */ Loading @@ -875,9 +923,22 @@ public class NumberPicker extends LinearLayout { return mCurrent; } @Override public int getSolidColor() { return mSolidColor; /** * Returns the range lower value of the NumberPicker. * * @return The lower number of the range. */ public int getRangeStart() { return mStart; } /** * Returns the range end value of the NumberPicker. * * @return The upper number of the range. */ public int getRangeEnd() { return mEnd; } @Override Loading Loading @@ -949,24 +1010,6 @@ public class NumberPicker extends LinearLayout { } } /** * Returns the upper value of the range of the NumberPicker * * @return the uppper number of the range. */ protected int getEndRange() { return mEnd; } /** * Returns the lower value of the range of the NumberPicker * * @return the lower number of the range. */ protected int getBeginRange() { return mStart; } /** * Sets the current value of this NumberPicker, and sets mPrevious to the * previous value. If current is greater than mEnd less than mStart, the Loading Loading @@ -1038,7 +1081,7 @@ public class NumberPicker extends LinearLayout { private void tryNotifyScrollListener(int scrollState) { if (mOnScrollListener != null && mScrollState != scrollState) { mScrollState = scrollState; mOnScrollListener.onScrollStateChanged(this, scrollState); mOnScrollListener.onScrollStateChange(this, scrollState); } } Loading Loading @@ -1238,8 +1281,8 @@ public class NumberPicker extends LinearLayout { * NumberPicker. */ private void notifyChange(int previous, int current) { if (mOnChangedListener != null) { mOnChangedListener.onChanged(this, previous, mCurrent); if (mOnChangeListener != null) { mOnChangeListener.onChange(this, previous, mCurrent); } } Loading Loading @@ -1439,7 +1482,7 @@ public class NumberPicker extends LinearLayout { public void run() { changeCurrent(mCurrent + mUpdateStep); postDelayed(this, mLongPressUpdateSpeed); postDelayed(this, mLongPressUpdateInterval); } } }
core/java/android/widget/TimePicker.java +8 −8 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.os.Parcelable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.NumberPicker.OnChangedListener; import android.widget.NumberPicker.OnChangeListener; import java.text.DateFormatSymbols; import java.util.Calendar; Loading Loading @@ -110,8 +110,8 @@ public class TimePicker extends FrameLayout { // hour mHourPicker = (NumberPicker) findViewById(R.id.hour); mHourPicker.setOnChangeListener(new NumberPicker.OnChangedListener() { public void onChanged(NumberPicker spinner, int oldVal, int newVal) { mHourPicker.setOnChangeListener(new NumberPicker.OnChangeListener() { public void onChange(NumberPicker spinner, int oldVal, int newVal) { mCurrentHour = newVal; if (!mIs24HourView) { // adjust from [1-12] to [0-11] internally, with the times Loading @@ -135,10 +135,10 @@ public class TimePicker extends FrameLayout { // digits of minute mMinutePicker = (NumberPicker) findViewById(R.id.minute); mMinutePicker.setRange(0, 59); mMinutePicker.setSpeed(100); mMinutePicker.setOnLongPressUpdateInterval(100); mMinutePicker.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER); mMinutePicker.setOnChangeListener(new NumberPicker.OnChangedListener() { public void onChanged(NumberPicker spinner, int oldVal, int newVal) { mMinutePicker.setOnChangeListener(new NumberPicker.OnChangeListener() { public void onChange(NumberPicker spinner, int oldVal, int newVal) { mCurrentMinute = newVal; onTimeChanged(); } Loading @@ -146,8 +146,8 @@ public class TimePicker extends FrameLayout { // am/pm mAmPmPicker = (NumberPicker) findViewById(R.id.amPm); mAmPmPicker.setOnChangeListener(new OnChangedListener() { public void onChanged(NumberPicker picker, int oldVal, int newVal) { mAmPmPicker.setOnChangeListener(new OnChangeListener() { public void onChange(NumberPicker picker, int oldVal, int newVal) { picker.requestFocus(); if (mIsAm) { // Currently AM switching to PM Loading