Skip to content

Commit

Permalink
[MaterialDatePicker] Hide month pagination from the year picker
Browse files Browse the repository at this point in the history
Resolves #2875

GIT_ORIGIN_REV_ID=b8c071d568282f16f8d9b498f2bbcba11be800db
PiperOrigin-RevId: 465055372
  • Loading branch information
pubiqq authored and drchen committed Aug 4, 2022
1 parent 24201b4 commit 51b6054
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ enum CalendarSelector {
private CalendarStyle calendarStyle;
private RecyclerView yearSelector;
private RecyclerView recyclerView;
private View monthPrev;
private View monthNext;
private View yearFrame;
private View dayFrame;

Expand Down Expand Up @@ -363,9 +365,13 @@ void setSelector(CalendarSelector selector) {
((YearGridAdapter) yearSelector.getAdapter()).getPositionForYear(current.year));
yearFrame.setVisibility(View.VISIBLE);
dayFrame.setVisibility(View.GONE);
monthPrev.setVisibility(View.GONE);
monthNext.setVisibility(View.GONE);
} else if (selector == CalendarSelector.DAY) {
yearFrame.setVisibility(View.GONE);
dayFrame.setVisibility(View.VISIBLE);
monthPrev.setVisibility(View.VISIBLE);
monthNext.setVisibility(View.VISIBLE);
// When visibility is toggled, the RecyclerView default opens to its lowest available id.
// This id is always one month earlier than current, so we force it to current.
setCurrentMonth(current);
Expand Down Expand Up @@ -399,9 +405,9 @@ public void onInitializeAccessibilityNodeInfo(
}
});

final MaterialButton monthPrev = root.findViewById(R.id.month_navigation_previous);
monthPrev = root.findViewById(R.id.month_navigation_previous);
monthPrev.setTag(NAVIGATION_PREV_TAG);
final MaterialButton monthNext = root.findViewById(R.id.month_navigation_next);
monthNext = root.findViewById(R.id.month_navigation_next);
monthNext.setTag(NAVIGATION_NEXT_TAG);

yearFrame = root.findViewById(R.id.mtrl_calendar_year_selector_frame);
Expand Down

0 comments on commit 51b6054

Please sign in to comment.