Skip to content

Commit

Permalink
Simplify setup method.
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Aug 10, 2019
1 parent f7fb445 commit d9d1dce
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d9d1dce

Please sign in to comment.