fix #812, fixing some sorting related glitches
This commit is contained in:
parent
15053ef67c
commit
2a9c368329
|
@ -13,6 +13,7 @@ import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
|||
import com.simplemobiletools.calendar.pro.extensions.seconds
|
||||
import com.simplemobiletools.calendar.pro.helpers.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.ListEvent
|
||||
import com.simplemobiletools.calendar.pro.models.ListItem
|
||||
import com.simplemobiletools.calendar.pro.models.ListSection
|
||||
|
@ -159,13 +160,19 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
|
|||
context.eventsHelper.getEventsSync(fromTS, toTS, applyTypeFilter = true) {
|
||||
val listItems = ArrayList<ListItem>(it.size)
|
||||
val replaceDescription = context.config.replaceDescription
|
||||
val sorted = it.sortedWith(compareBy({
|
||||
val sorted = it.sortedWith(compareBy<Event> {
|
||||
if (it.getIsAllDay()) {
|
||||
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS))
|
||||
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS)) - 1
|
||||
} else {
|
||||
it.startTS
|
||||
}
|
||||
}, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
|
||||
}.thenBy {
|
||||
if (it.getIsAllDay()) {
|
||||
Formatter.getDayEndTS(Formatter.getDayCodeFromTS(it.endTS))
|
||||
} else {
|
||||
it.endTS
|
||||
}
|
||||
}.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description })
|
||||
|
||||
var prevCode = ""
|
||||
val now = getNowSeconds()
|
||||
|
|
|
@ -393,7 +393,19 @@ private fun addTodaysBackground(textView: TextView, res: Resources, dayLabelHeig
|
|||
fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resources, dividerMargin: Int) {
|
||||
val eventLayoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
|
||||
day.dayEvents.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title })).forEach {
|
||||
day.dayEvents.sortedWith(compareBy<Event> {
|
||||
if (it.getIsAllDay()) {
|
||||
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS)) - 1
|
||||
} else {
|
||||
it.startTS
|
||||
}
|
||||
}.thenBy {
|
||||
if (it.getIsAllDay()) {
|
||||
Formatter.getDayEndTS(Formatter.getDayCodeFromTS(it.endTS))
|
||||
} else {
|
||||
it.endTS
|
||||
}
|
||||
}.thenBy { it.title }).forEach {
|
||||
val backgroundDrawable = res.getDrawable(R.drawable.day_monthly_event_background)
|
||||
backgroundDrawable.applyColorFilter(it.color)
|
||||
eventLayoutParams.setMargins(dividerMargin, 0, dividerMargin, dividerMargin)
|
||||
|
@ -420,13 +432,19 @@ fun Context.getEventListItems(events: List<Event>): ArrayList<ListItem> {
|
|||
val replaceDescription = config.replaceDescription
|
||||
|
||||
// move all-day events in front of others
|
||||
val sorted = events.sortedWith(compareBy({
|
||||
val sorted = events.sortedWith(compareBy<Event> {
|
||||
if (it.getIsAllDay()) {
|
||||
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS))
|
||||
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS)) - 1
|
||||
} else {
|
||||
it.startTS
|
||||
}
|
||||
}, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
|
||||
}.thenBy {
|
||||
if (it.getIsAllDay()) {
|
||||
Formatter.getDayEndTS(Formatter.getDayCodeFromTS(it.endTS))
|
||||
} else {
|
||||
it.endTS
|
||||
}
|
||||
}.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description })
|
||||
|
||||
var prevCode = ""
|
||||
val now = getNowSeconds()
|
||||
|
|
|
@ -259,7 +259,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
|
||||
var hadAllDayEvent = false
|
||||
val replaceDescription = mConfig.replaceDescription
|
||||
val sorted = events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
|
||||
val sorted = events.sortedWith(compareBy<Event> { it.startTS }.thenBy { it.endTS }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description })
|
||||
for (event in sorted) {
|
||||
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
|
||||
val endDateTime = Formatter.getDateTimeFromTS(event.endTS)
|
||||
|
|
Loading…
Reference in New Issue