Fix sorting in month view to startTS -> endTS -> title

This commit is contained in:
Paul Akhamiogu 2021-08-12 17:57:56 +01:00
parent 2f7664c8b7
commit 37dc872940
2 changed files with 3 additions and 3 deletions

View file

@ -1,4 +1,4 @@
package com.simplemobiletools.calendar.pro.models package com.simplemobiletools.calendar.pro.models
data class MonthViewEvent(val id: Long, val title: String, val startTS: Long, val color: Int, val startDayIndex: Int, val daysCnt: Int, val originalStartDayIndex: Int, data class MonthViewEvent(val id: Long, val title: String, val startTS: Long, val endTS: Long, val color: Int, val startDayIndex: Int, val daysCnt: Int, val originalStartDayIndex: Int,
val isAllDay: Boolean, val isPastEvent: Boolean) val isAllDay: Boolean, val isPastEvent: Boolean)

View file

@ -121,14 +121,14 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
val daysCnt = getEventLastingDaysCount(event) val daysCnt = getEventLastingDaysCount(event)
val validDayEvent = isDayValid(event, day.code) val validDayEvent = isDayValid(event, day.code)
if ((lastEvent == null || lastEvent.startDayIndex + daysCnt <= day.indexOnMonthView) && !validDayEvent) { if ((lastEvent == null || lastEvent.startDayIndex + daysCnt <= day.indexOnMonthView) && !validDayEvent) {
val monthViewEvent = MonthViewEvent(event.id!!, event.title, event.startTS, event.color, day.indexOnMonthView, val monthViewEvent = MonthViewEvent(event.id!!, event.title, event.startTS, event.endTS, event.color, day.indexOnMonthView,
daysCnt, day.indexOnMonthView, event.getIsAllDay(), event.isPastEvent) daysCnt, day.indexOnMonthView, event.getIsAllDay(), event.isPastEvent)
allEvents.add(monthViewEvent) allEvents.add(monthViewEvent)
} }
} }
} }
allEvents = allEvents.asSequence().sortedWith(compareBy({ -it.daysCnt }, { !it.isAllDay }, { it.startTS }, { it.startDayIndex }, { it.title })) allEvents = allEvents.asSequence().sortedWith(compareBy({ -it.daysCnt }, { !it.isAllDay }, { it.startTS }, { it.endTS }, { it.startDayIndex }, { it.title }))
.toMutableList() as ArrayList<MonthViewEvent> .toMutableList() as ArrayList<MonthViewEvent>
} }