summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/widget/CalendarViewLegacyDelegate.java8
-rw-r--r--core/java/android/widget/DayPickerView.java16
2 files changed, 19 insertions, 5 deletions
diff --git a/core/java/android/widget/CalendarViewLegacyDelegate.java b/core/java/android/widget/CalendarViewLegacyDelegate.java
index 91eaab81abcc..bcda83fbd95c 100644
--- a/core/java/android/widget/CalendarViewLegacyDelegate.java
+++ b/core/java/android/widget/CalendarViewLegacyDelegate.java
@@ -789,14 +789,14 @@ class CalendarViewLegacyDelegate extends CalendarView.AbstractCalendarViewDelega
* @param forceScroll Whether to recenter even if the time is already
* visible.
*
- * @throws IllegalArgumentException of the provided date is before the
- * range start of after the range end.
+ * @throws IllegalArgumentException if the provided date is before the
+ * range start or after the range end.
*/
private void goTo(Calendar date, boolean animate, boolean setSelected,
boolean forceScroll) {
if (date.before(mMinDate) || date.after(mMaxDate)) {
- throw new IllegalArgumentException("Time not between " + mMinDate.getTime()
- + " and " + mMaxDate.getTime());
+ throw new IllegalArgumentException("timeInMillis must be between the values of "
+ + "getMinDate() and getMaxDate()");
}
// Find the first and last entirely visible weeks
int firstFullyVisiblePosition = mListView.getFirstVisiblePosition();
diff --git a/core/java/android/widget/DayPickerView.java b/core/java/android/widget/DayPickerView.java
index 7e950f785600..0c02a2ba61fa 100644
--- a/core/java/android/widget/DayPickerView.java
+++ b/core/java/android/widget/DayPickerView.java
@@ -16,6 +16,8 @@
package android.widget;
+import static android.os.Build.VERSION_CODES.N_MR1;
+
import android.graphics.Rect;
import com.android.internal.R;
import com.android.internal.widget.ViewPager;
@@ -291,8 +293,21 @@ class DayPickerView extends ViewGroup {
* @param timeInMillis the target day in milliseconds
* @param animate whether to smooth scroll to the new position
* @param setSelected whether to set the specified day as selected
+ *
+ * @throws IllegalArgumentException as of {@link android.os.Build.VERSION_CODES#N_MR1} if the
+ * provided timeInMillis is before the range start or after the range end.
*/
private void setDate(long timeInMillis, boolean animate, boolean setSelected) {
+ getTempCalendarForTime(timeInMillis);
+
+ final int targetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
+ if (targetSdkVersion >= N_MR1) {
+ if (mTempCalendar.before(mMinDate) || mTempCalendar.after(mMaxDate)) {
+ throw new IllegalArgumentException("timeInMillis must be between the values of "
+ + "getMinDate() and getMaxDate()");
+ }
+ }
+
if (setSelected) {
mSelectedDay.setTimeInMillis(timeInMillis);
}
@@ -302,7 +317,6 @@ class DayPickerView extends ViewGroup {
mViewPager.setCurrentItem(position, animate);
}
- mTempCalendar.setTimeInMillis(timeInMillis);
mAdapter.setSelectedDay(mTempCalendar);
}