diff options
| author | Kenneth Andersson <kenneth.andersson@sonyericsson.com> | 2010-03-05 09:16:24 +0100 |
|---|---|---|
| committer | Johan Redestig <johan.redestig@sonyericsson.com> | 2010-03-06 10:04:41 +0100 |
| commit | e3491b6b5f1d3fb871074766597b275d9f682faa (patch) | |
| tree | b62761a8200878ae3919dcf7e51305f9bd03a7fc /core/java/android/widget/DatePicker.java | |
| parent | 7bb2581e6f404da0edba9ebb81b0d0593715eb40 (diff) | |
Title in DatePickerDialog used in Settings application not updated correctly
The DatePickerDialog in the Settings application is not updated correctly if you follow
the following step-by-step:
1. Enter Date option in settings application
2. Modify the values of the date, then cancel the changes
3. Once again enter the date option
and you can see that the title in the dialog has not been updated correctly. This is
due to a missing call to onDateChanged callback in the DatePicker class. Solution was
to add the notify call when updateTime has been called.
Diffstat (limited to 'core/java/android/widget/DatePicker.java')
| -rw-r--r-- | core/java/android/widget/DatePicker.java | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 5e76cc3a28af..736475e6fecf 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -94,9 +94,7 @@ public class DatePicker extends FrameLayout { mDayPicker.setOnChangeListener(new OnChangedListener() { public void onChanged(NumberPicker picker, int oldVal, int newVal) { mDay = newVal; - if (mOnDateChangedListener != null) { - mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay); - } + notifyDateChanged(); } }); mMonthPicker = (NumberPicker) findViewById(R.id.month); @@ -114,9 +112,7 @@ public class DatePicker extends FrameLayout { mMonth = newVal - 1; // Adjust max day of the month adjustMaxDay(); - if (mOnDateChangedListener != null) { - mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay); - } + notifyDateChanged(); updateDaySpinner(); } }); @@ -127,9 +123,7 @@ public class DatePicker extends FrameLayout { mYear = newVal; // Adjust max day for leap years if needed adjustMaxDay(); - if (mOnDateChangedListener != null) { - mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay); - } + notifyDateChanged(); updateDaySpinner(); } }); @@ -230,11 +224,14 @@ public class DatePicker extends FrameLayout { } public void updateDate(int year, int monthOfYear, int dayOfMonth) { - mYear = year; - mMonth = monthOfYear; - mDay = dayOfMonth; - updateSpinners(); - reorderPickers(new DateFormatSymbols().getShortMonths()); + if (mYear != year || mMonth != monthOfYear || mDay != dayOfMonth) { + mYear = year; + mMonth = monthOfYear; + mDay = dayOfMonth; + updateSpinners(); + reorderPickers(new DateFormatSymbols().getShortMonths()); + notifyDateChanged(); + } } private static class SavedState extends BaseSavedState { @@ -376,4 +373,10 @@ public class DatePicker extends FrameLayout { mDay = max; } } + + private void notifyDateChanged() { + if (mOnDateChangedListener != null) { + mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay); + } + } } |
