Skip to content

Commit c484ea7

Browse files
paulfthomasraajkumars
authored andcommitted
[MaterialCalendar] Fix NPE
PiperOrigin-RevId: 502984835
1 parent 4c31ab5 commit c484ea7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/java/com/google/android/material/datepicker/MaterialCalendar.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,12 @@ public void onDraw(
302302
}
303303
int top = viewInRow.getTop() + calendarStyle.year.getTopInset();
304304
int bottom = viewInRow.getBottom() - calendarStyle.year.getBottomInset();
305-
int left = row == firstRow ? firstView.getLeft() + firstView.getWidth() / 2 : 0;
305+
int left =
306+
row == firstRow && firstView != null
307+
? firstView.getLeft() + firstView.getWidth() / 2
308+
: 0;
306309
int right =
307-
row == lastRow
310+
row == lastRow && lastView != null
308311
? lastView.getLeft() + lastView.getWidth() / 2
309312
: recyclerView.getWidth();
310313
canvas.drawRect(left, top, right, bottom, calendarStyle.rangeFill);

0 commit comments

Comments
 (0)