Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02dba53f authored by Andrei Stingaceanu's avatar Andrei Stingaceanu Committed by android-build-merger
Browse files

Merge "DayPickerView - clamp date to min/max" into oc-dev am: 511c95a0 am: 37aa78bf

am: 852f4b1f

Change-Id: I317b1c2891426225863711e4815a470d1902a9a2
parents 0c860748 852f4b1f
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -293,9 +293,19 @@ class DayPickerView extends ViewGroup {
     * @param setSelected whether to set the specified day as selected
     */
    private void setDate(long timeInMillis, boolean animate, boolean setSelected) {
        boolean dateClamped = false;
        // Clamp the target day in milliseconds to the min or max if outside the range.
        if (timeInMillis < mMinDate.getTimeInMillis()) {
            timeInMillis = mMinDate.getTimeInMillis();
            dateClamped = true;
        } else if (timeInMillis > mMaxDate.getTimeInMillis()) {
            timeInMillis = mMaxDate.getTimeInMillis();
            dateClamped = true;
        }

        getTempCalendarForTime(timeInMillis);

        if (setSelected) {
        if (setSelected || dateClamped) {
            mSelectedDay.setTimeInMillis(timeInMillis);
        }

@@ -353,13 +363,6 @@ class DayPickerView extends ViewGroup {
    public void onRangeChanged() {
        mAdapter.setRange(mMinDate, mMaxDate);

        // Clamp the selected day to the new min/max.
        if (mSelectedDay.before(mMinDate)) {
            mSelectedDay.setTimeInMillis(mMinDate.getTimeInMillis());
        } else if (mSelectedDay.after(mMaxDate)) {
            mSelectedDay.setTimeInMillis(mMaxDate.getTimeInMillis());
        }

        // Changing the min/max date changes the selection position since we
        // don't really have stable IDs. Jumps immediately to the new position.
        setDate(mSelectedDay.getTimeInMillis(), false, false);