Fixes minimum date in DatePicker

Fixes: 158448787

When the day is earlier in than the minimum date, but
the year is later, then the year is changed, the date
gets set to a day that is earlier than the minimum date.
This CL ensures that the year change can't bring the
date outside of the range of minimum to maximum dates.

Test: manual testing
Change-Id: I0034bd513275267ecf9554f673533852e68dd854
This commit is contained in:
George Mount
2021-05-14 20:23:37 +00:00
parent c70b38a9f8
commit 4f2b9ad2bd

View File

@@ -259,6 +259,11 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
}
mCurrentDate.set(Calendar.YEAR, year);
if (mCurrentDate.compareTo(mMinDate) < 0) {
mCurrentDate.setTimeInMillis(mMinDate.getTimeInMillis());
} else if (mCurrentDate.compareTo(mMaxDate) > 0) {
mCurrentDate.setTimeInMillis(mMaxDate.getTimeInMillis());
}
onDateChanged(true, true);
// Automatically switch to day picker.