From d7419986ca79e5408f247fbfcad2c5dc2966a9e0 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Tue, 11 Jan 2011 17:57:08 -0800 Subject: [PATCH] Down arrow on the month can end up at the start of the month bug:3338078 1. The bug was that I was claculating delta month and day from the current date but was changing the latter in the middle thus causing inconsistent state. Change-Id: Id3082b01778fc2b3116aa412aff3f12e9ebf0c97 --- core/java/android/widget/DatePicker.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 821e1f65daec6..fce24496d2fce 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -514,10 +514,11 @@ public class DatePicker extends FrameLayout { * inconsistent date the values are normalized before updating the spinners. */ private void updateSpinners(int year, int month, int dayOfMonth) { - mCurrentDate.set(Calendar.YEAR, year); + // compute the deltas before modifying the current date int deltaMonths = getDelataMonth(month); - mCurrentDate.add(Calendar.MONTH, deltaMonths); int deltaDays = getDelataDayOfMonth(dayOfMonth); + mCurrentDate.set(Calendar.YEAR, year); + mCurrentDate.add(Calendar.MONTH, deltaMonths); mCurrentDate.add(Calendar.DAY_OF_MONTH, deltaDays); if (mCurrentDate.before(mMinDate)) {