mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 12:20:51 +01:00
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.extensions.seconds
|
||||||
import com.simplemobiletools.calendar.pro.helpers.*
|
import com.simplemobiletools.calendar.pro.helpers.*
|
||||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
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.ListEvent
|
||||||
import com.simplemobiletools.calendar.pro.models.ListItem
|
import com.simplemobiletools.calendar.pro.models.ListItem
|
||||||
import com.simplemobiletools.calendar.pro.models.ListSection
|
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) {
|
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({
|
val sorted = it.sortedWith(compareBy<Event> {
|
||||||
if (it.getIsAllDay()) {
|
if (it.getIsAllDay()) {
|
||||||
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS))
|
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS)) - 1
|
||||||
} else {
|
} else {
|
||||||
it.startTS
|
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 = ""
|
var prevCode = ""
|
||||||
val now = getNowSeconds()
|
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) {
|
fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resources, dividerMargin: Int) {
|
||||||
val eventLayoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
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)
|
val backgroundDrawable = res.getDrawable(R.drawable.day_monthly_event_background)
|
||||||
backgroundDrawable.applyColorFilter(it.color)
|
backgroundDrawable.applyColorFilter(it.color)
|
||||||
eventLayoutParams.setMargins(dividerMargin, 0, dividerMargin, dividerMargin)
|
eventLayoutParams.setMargins(dividerMargin, 0, dividerMargin, dividerMargin)
|
||||||
@ -420,13 +432,19 @@ fun Context.getEventListItems(events: List<Event>): ArrayList<ListItem> {
|
|||||||
val replaceDescription = config.replaceDescription
|
val replaceDescription = config.replaceDescription
|
||||||
|
|
||||||
// move all-day events in front of others
|
// move all-day events in front of others
|
||||||
val sorted = events.sortedWith(compareBy({
|
val sorted = events.sortedWith(compareBy<Event> {
|
||||||
if (it.getIsAllDay()) {
|
if (it.getIsAllDay()) {
|
||||||
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS))
|
Formatter.getDayStartTS(Formatter.getDayCodeFromTS(it.startTS)) - 1
|
||||||
} else {
|
} else {
|
||||||
it.startTS
|
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 = ""
|
var prevCode = ""
|
||||||
val now = getNowSeconds()
|
val now = getNowSeconds()
|
||||||
|
@ -259,7 +259,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||||||
|
|
||||||
var hadAllDayEvent = false
|
var hadAllDayEvent = false
|
||||||
val replaceDescription = mConfig.replaceDescription
|
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) {
|
for (event in sorted) {
|
||||||
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
|
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
|
||||||
val endDateTime = Formatter.getDateTimeFromTS(event.endTS)
|
val endDateTime = Formatter.getDateTimeFromTS(event.endTS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user