From d9d1dceccf63f36e7fc176f3b29c29487954faa4 Mon Sep 17 00:00:00 2001 From: Kizito Nwose Date: Sat, 10 Aug 2019 12:09:42 +0100 Subject: [PATCH] Simplify setup method. --- .../com/kizitonwose/calendarview/CalendarView.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/com/kizitonwose/calendarview/CalendarView.kt b/library/src/main/java/com/kizitonwose/calendarview/CalendarView.kt index 82db2d99..9b35352f 100644 --- a/library/src/main/java/com/kizitonwose/calendarview/CalendarView.kt +++ b/library/src/main/java/com/kizitonwose/calendarview/CalendarView.kt @@ -586,18 +586,19 @@ open class CalendarView : RecyclerView { * @param firstDayOfWeek An instance of [DayOfWeek] enum to be the first day of week. */ fun setup(startMonth: YearMonth, endMonth: YearMonth, firstDayOfWeek: DayOfWeek) { - if (this.startMonth != null && this.endMonth != null && this.firstDayOfWeek != null) { - this.startMonth = startMonth - this.endMonth = endMonth - this.firstDayOfWeek = firstDayOfWeek - updateAdapterMonthConfig(saveScroll = true) - return // Only update the months on the calendar, no need for a full setup. - } + val oldStartMonth = this.startMonth + val oldEndMonth = this.endMonth + val oldFirstDayOfWeek = this.firstDayOfWeek this.startMonth = startMonth this.endMonth = endMonth this.firstDayOfWeek = firstDayOfWeek + if (oldStartMonth != null && oldEndMonth != null && oldFirstDayOfWeek != null) { + updateAdapterMonthConfig(saveScroll = true) + return // Only update the months on the calendar, no need for a full setup. + } + clipToPadding = false clipChildren = false //#ClipChildrenFix