From 884a4128ac16e49ac356ca3176e57fd6ff67635a Mon Sep 17 00:00:00 2001 From: Wouter Dullaert Date: Sat, 9 Feb 2019 16:57:13 +0100 Subject: [PATCH] Log a warning when trying to announce before interface has been initialized Fixes #561 --- .../wdullaer/materialdatetimepicker/date/DayPickerView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/wdullaer/materialdatetimepicker/date/DayPickerView.java b/library/src/main/java/com/wdullaer/materialdatetimepicker/date/DayPickerView.java index e558d63e..885b9297 100644 --- a/library/src/main/java/com/wdullaer/materialdatetimepicker/date/DayPickerView.java +++ b/library/src/main/java/com/wdullaer/materialdatetimepicker/date/DayPickerView.java @@ -259,7 +259,7 @@ public int getMostVisiblePosition() { return getChildAdapterPosition(getMostVisibleMonth()); } - public MonthView getMostVisibleMonth() { + public @Nullable MonthView getMostVisibleMonth() { boolean verticalScroll = mController.getScrollOrientation() == DatePickerDialog.ScrollOrientation.VERTICAL; final int maxSize = verticalScroll ? getHeight() : getWidth(); int maxDisplayedSize = 0; @@ -358,6 +358,8 @@ void accessibilityAnnouncePageChanged() { if (mv != null) { String monthYear = getMonthAndYearString(mv.mMonth, mv.mYear, mController.getLocale()); Utils.tryAccessibilityAnnounce(this, monthYear); + } else { + Log.w("DayPickerView", "Tried to announce before layout was initialized"); } }