@@ -97,6 +97,7 @@ enum CalendarSelector {
9797 private MaterialButton monthDropSelect ;
9898 private AccessibilityManager accessibilityManager ;
9999 @ Nullable private PagerSnapHelper pagerSnapHelper ;
100+ private boolean isFullscreen ;
100101
101102 @ NonNull
102103 public static <T > MaterialCalendar <T > newInstance (
@@ -161,7 +162,8 @@ public View onCreateView(
161162
162163 int layout ;
163164 final int orientation ;
164- if (MaterialDatePicker .isFullscreen (themedContext )) {
165+ isFullscreen = MaterialDatePicker .isFullscreen (themedContext );
166+ if (isFullscreen ) {
165167 layout = R .layout .mtrl_calendar_vertical ;
166168 orientation = LinearLayoutManager .VERTICAL ;
167169 } else {
@@ -233,12 +235,12 @@ public void onDayClick(long day) {
233235 new OnMonthNavigationListener () {
234236 @ Override
235237 public boolean onMonthNavigationPrevious () {
236- return handleNavigateToMonthForKeyboard (/* forward= */ false , themedContext );
238+ return handleNavigateToMonthForKeyboard (/* forward= */ false );
237239 }
238240
239241 @ Override
240242 public boolean onMonthNavigationNext () {
241- return handleNavigateToMonthForKeyboard (/* forward= */ true , themedContext );
243+ return handleNavigateToMonthForKeyboard (/* forward= */ true );
242244 }
243245 });
244246 recyclerView .setAdapter (monthsPagerAdapter );
@@ -254,7 +256,7 @@ public boolean onMonthNavigationNext() {
254256 yearSelector .addItemDecoration (createItemDecoration ());
255257 }
256258
257- if (!MaterialDatePicker . isFullscreen ( themedContext ) ) {
259+ if (!isFullscreen ) {
258260 pagerSnapHelper = new PagerSnapHelper ();
259261 pagerSnapHelper .attachToRecyclerView (recyclerView );
260262 }
@@ -354,11 +356,10 @@ CalendarConstraints getCalendarConstraints() {
354356 *
355357 * @param forward {@code true} to navigate to the next month, {@code false} to navigate to the
356358 * previous month.
357- * @param context The context.
358359 * @return {@code true} if the event was handled.
359360 */
360- private boolean handleNavigateToMonthForKeyboard (boolean forward , @ NonNull Context context ) {
361- if (MaterialDatePicker . isFullscreen ( context ) ) {
361+ private boolean handleNavigateToMonthForKeyboard (boolean forward ) {
362+ if (isFullscreen ) {
362363 return false ;
363364 }
364365
@@ -416,13 +417,8 @@ void setCurrentMonth(Month moveTo) {
416417 }
417418
418419 private void updateCurrentVisibleMonth () {
419- Context context = getContext ();
420- if (context == null || MaterialDatePicker .isFullscreen (context )) {
421- return ;
422- }
423-
424420 MonthsPagerAdapter adapter = (MonthsPagerAdapter ) recyclerView .getAdapter ();
425- if (adapter != null ) {
421+ if (adapter != null && ! isFullscreen ) {
426422 adapter .setVisibleMonth (current );
427423 }
428424 }
0 commit comments