fix #726, move all-day events in fron of others at list views

This commit is contained in:
tibbi
2018-12-19 18:31:32 +01:00
parent ef646e81bf
commit 8245d50cf5
2 changed files with 18 additions and 2 deletions

View File

@@ -159,7 +159,14 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
context.eventsHelper.getEventsSync(fromTS, toTS, applyTypeFilter = true) { context.eventsHelper.getEventsSync(fromTS, toTS, applyTypeFilter = true) {
val listItems = ArrayList<ListItem>(it.size) val listItems = ArrayList<ListItem>(it.size)
val replaceDescription = context.config.replaceDescription val replaceDescription = context.config.replaceDescription
val sorted = it.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description })) val sorted = it.sortedWith(compareBy({
if (it.getIsAllDay()) {
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS))
} else {
it.startTS
}
}, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
var prevCode = "" var prevCode = ""
val now = getNowSeconds() val now = getNowSeconds()
val today = Formatter.getDayTitle(context, Formatter.getDayCodeFromTS(now)) val today = Formatter.getDayTitle(context, Formatter.getDayCodeFromTS(now))

View File

@@ -399,7 +399,16 @@ fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resou
fun Context.getEventListItems(events: List<Event>): ArrayList<ListItem> { fun Context.getEventListItems(events: List<Event>): ArrayList<ListItem> {
val listItems = ArrayList<ListItem>(events.size) val listItems = ArrayList<ListItem>(events.size)
val replaceDescription = config.replaceDescription val replaceDescription = config.replaceDescription
val sorted = events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
// move all-day events in front of others
val sorted = events.sortedWith(compareBy({
if (it.getIsAllDay()) {
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS))
} else {
it.startTS
}
}, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
var prevCode = "" var prevCode = ""
val now = getNowSeconds() val now = getNowSeconds()
val today = Formatter.getDayTitle(this, Formatter.getDayCodeFromTS(now)) val today = Formatter.getDayTitle(this, Formatter.getDayCodeFromTS(now))