From ac55c060d51f53723ae43fad7955d7cd2cfe6675 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sat, 21 May 2022 20:29:40 +0530 Subject: [PATCH] Minor readability improvements --- .../simplemobiletools/calendar/pro/views/MonthView.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt index f785d1520..d29199e1a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/MonthView.kt @@ -123,9 +123,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con val daysCnt = getEventLastingDaysCount(event) val validDayEvent = isDayValid(event, day.code) - val lastDay = { findLastDay(event) ?: day } - - if ((lastEvent == null || lastEvent.startDayIndex + daysCnt <= lastDay().indexOnMonthView) && !validDayEvent) { + if ((lastEvent == null || lastEvent.startDayIndex + daysCnt <= findLastDay(event).indexOnMonthView) && !validDayEvent) { val monthViewEvent = MonthViewEvent( event.id!!, event.title, event.startTS, event.endTS, event.color, day.indexOnMonthView, daysCnt, day.indexOnMonthView, event.getIsAllDay(), event.isPastEvent, event.isTask(), event.isTaskCompleted() @@ -433,10 +431,11 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con return event.startTS != event.endTS && Formatter.getDateTimeFromTS(event.endTS) == Formatter.getDateTimeFromTS(date.seconds()).withTimeAtStartOfDay() } - private fun findLastDay(event: Event) = - days.lastOrNull { day -> + private fun findLastDay(event: Event): DayMonthly { + return days.last { day -> day.dayEvents.find { it.id == event.id } != null } + } fun togglePrintMode() { isPrintVersion = !isPrintVersion