summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-07-14 16:03:30 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-07-14 16:03:30 -0700
commit4764605109a0dd993a805b368897f93ab29e8996 (patch)
tree86d484a5d72b5bd340627890299ae9b44743cede /core/java
parent24b03ace12dab2c786d5ba33b92be3f5b162982b (diff)
parentfa8904a683903524ed9749f296e80381e5820178 (diff)
downloadframeworks_base-4764605109a0dd993a805b368897f93ab29e8996.zip
frameworks_base-4764605109a0dd993a805b368897f93ab29e8996.tar.gz
frameworks_base-4764605109a0dd993a805b368897f93ab29e8996.tar.bz2
am fa8904a6: Merge change 7012 into donut
Merge commit 'fa8904a683903524ed9749f296e80381e5820178' * commit 'fa8904a683903524ed9749f296e80381e5820178': Fix couple of issues in DatePicker
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/DatePicker.java15
-rw-r--r--core/java/com/android/internal/widget/NumberPicker.java8
2 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 54f2707..3b9f1de 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -110,6 +110,8 @@ public class DatePicker extends FrameLayout {
* subtract by one to ensure our internal state is always 0-11
*/
mMonth = newVal - 1;
+ // Adjust max day of the month
+ adjustMaxDay();
if (mOnDateChangedListener != null) {
mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
}
@@ -121,9 +123,12 @@ public class DatePicker extends FrameLayout {
mYearPicker.setOnChangeListener(new OnChangedListener() {
public void onChanged(NumberPicker picker, int oldVal, int newVal) {
mYear = newVal;
+ // Adjust max day for leap years if needed
+ adjustMaxDay();
if (mOnDateChangedListener != null) {
mOnDateChangedListener.onDateChanged(DatePicker.this, mYear, mMonth, mDay);
}
+ updateDaySpinner();
}
});
@@ -318,4 +323,14 @@ public class DatePicker extends FrameLayout {
public int getDayOfMonth() {
return mDay;
}
+
+ private void adjustMaxDay(){
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, mYear);
+ cal.set(Calendar.MONTH, mMonth);
+ int max = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
+ if (mDay > max) {
+ mDay = max;
+ }
+ }
}
diff --git a/core/java/com/android/internal/widget/NumberPicker.java b/core/java/com/android/internal/widget/NumberPicker.java
index 2f08c8d..0424ced 100644
--- a/core/java/com/android/internal/widget/NumberPicker.java
+++ b/core/java/com/android/internal/widget/NumberPicker.java
@@ -243,9 +243,11 @@ public class NumberPicker extends LinearLayout implements OnClickListener,
private void validateCurrentView(CharSequence str) {
int val = getSelectedPos(str.toString());
if ((val >= mStart) && (val <= mEnd)) {
- mPrevious = mCurrent;
- mCurrent = val;
- notifyChange();
+ if (mCurrent != val) {
+ mPrevious = mCurrent;
+ mCurrent = val;
+ notifyChange();
+ }
}
updateView();
}