prolificinteractive / material-calendarview

A Material design back port of Android's CalendarView
https://prolificinteractive.github.io/material-calendarview/
MIT License
5.91k stars 1.32k forks source link

Range decorator does not get applied after orientation change #1019

Closed gauravbarthwal closed 4 years ago

gauravbarthwal commented 4 years ago

I have implemented a range selection mode calendar view. If I select a range and change the orientation and call calendarView.selectRange(first, last) with last selected range, I do not see the decorator. After debugging the code I found that onRangeSelected(widget: MaterialCalendarView, dates: List<CalendarDay>) gets the callback nut decorator does not get applied.

I am using 2.0.0 version of the library.

gauravbarthwal commented 4 years ago

Found the issue on onRestoreInstanceState(). The setSelectionMode(ss.selectionMode); should come before

clearSelection();
    for (CalendarDay calendarDay : ss.selectedDates) {
      setDateSelected(calendarDay, true);
    }

You can solve the issue without changing on the library. Just reset the calendar values in onResume().