Skip to content

Commit

Permalink
Fix NPE from MaterialDatePicker rotation when MaterialCalendar is not…
Browse files Browse the repository at this point in the history
… visible.

calendar.getCurrentMonth() is nullable so we check before accessing

PiperOrigin-RevId: 268290292
  • Loading branch information
ldjcmu authored and dsn5ft committed Oct 3, 2019
1 parent 340497a commit e0a4d4e
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,13 @@ public final void onSaveInstanceState(@NonNull Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putInt(OVERRIDE_THEME_RES_ID, overrideThemeResId);
bundle.putParcelable(GRID_SELECTOR_KEY, dateSelector);
bundle.putParcelable(
CALENDAR_CONSTRAINTS_KEY,
new CalendarConstraints.Builder(calendarConstraints)
.setOpenAt(calendar.getCurrentMonth().timeInMillis)
.build());

CalendarConstraints.Builder constraintsBuilder =
new CalendarConstraints.Builder(calendarConstraints);
if (calendar.getCurrentMonth() != null) {
constraintsBuilder.setOpenAt(calendar.getCurrentMonth().timeInMillis);
}
bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, constraintsBuilder.build());
bundle.putInt(TITLE_TEXT_RES_ID_KEY, titleTextResId);
}

Expand Down

0 comments on commit e0a4d4e

Please sign in to comment.