From 0383f59f44fe4fda80d1e9b5cd09d8649d10fe0c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 22 Mar 2020 22:28:42 +0100 Subject: [PATCH] move event sorting at the weekly view a bit up --- .../calendar/pro/fragments/WeekFragment.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index dc8df1721..67cf05d49 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -236,7 +236,12 @@ class WeekFragment : Fragment(), WeeklyCalendar { activity!!.runOnUiThread { if (context != null && activity != null && isAdded) { - addEvents(events) + val replaceDescription = config.replaceDescription + val sorted = events.sortedWith( + compareBy { it.startTS }.thenBy { it.endTS }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description } + ).toMutableList() as ArrayList + + addEvents(sorted) } } } @@ -257,12 +262,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { val density = Math.round(res.displayMetrics.density) var hadAllDayEvent = false - val replaceDescription = config.replaceDescription - val sorted = events.sortedWith( - compareBy { it.startTS }.thenBy { it.endTS }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description } - ) - for (event in sorted) { + for (event in events) { val startDateTime = Formatter.getDateTimeFromTS(event.startTS) val endDateTime = Formatter.getDateTimeFromTS(event.endTS) if (!event.getIsAllDay() && Formatter.getDayCodeFromDateTime(startDateTime) == Formatter.getDayCodeFromDateTime(endDateTime)) { @@ -280,7 +281,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } - for (event in sorted) { + for (event in events) { val startDateTime = Formatter.getDateTimeFromTS(event.startTS) val endDateTime = Formatter.getDateTimeFromTS(event.endTS) if (event.getIsAllDay() || Formatter.getDayCodeFromDateTime(startDateTime) != Formatter.getDayCodeFromDateTime(endDateTime)) {