File tree Expand file tree Collapse file tree 1 file changed +10
-18
lines changed
lib/java/com/google/android/material/datepicker Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -587,24 +587,16 @@ public void onClick(View view) {
587587 }
588588 });
589589
590- monthNext .setOnClickListener (
591- new OnClickListener () {
592- @ Override
593- public void onClick (View view ) {
594- int currentItem = getLayoutManager ().findFirstVisibleItemPosition ();
595- monthsPagerAdapter .setKeyboardFocusDirection (View .FOCUS_FORWARD );
596- setCurrentMonth (monthsPagerAdapter .getPageMonth (currentItem + 1 ));
597- }
598- });
599- monthPrev .setOnClickListener (
600- new OnClickListener () {
601- @ Override
602- public void onClick (View view ) {
603- int currentItem = getLayoutManager ().findLastVisibleItemPosition ();
604- monthsPagerAdapter .setKeyboardFocusDirection (View .FOCUS_BACKWARD );
605- setCurrentMonth (monthsPagerAdapter .getPageMonth (currentItem - 1 ));
606- }
607- });
590+ monthNext .setOnClickListener (view -> {
591+ monthsPagerAdapter .setKeyboardFocusDirection (View .FOCUS_FORWARD );
592+ Month currentMonth = getCurrentMonth ();
593+ setCurrentMonth (currentMonth .monthsLater (1 ));
594+ });
595+ monthPrev .setOnClickListener (view -> {
596+ monthsPagerAdapter .setKeyboardFocusDirection (View .FOCUS_BACKWARD );
597+ Month currentMonth = getCurrentMonth ();
598+ setCurrentMonth (currentMonth .monthsLater (-1 ));
599+ });
608600
609601 int currentMonthPosition = monthsPagerAdapter .getPosition (current );
610602 updateNavigationButtonsEnabled (currentMonthPosition );
You can’t perform that action at this time.
0 commit comments