show all-day events above others on some views in some cases

This commit is contained in:
tibbi
2018-03-26 14:55:20 +02:00
parent 687927b24a
commit 34c145d328
3 changed files with 8 additions and 6 deletions

View File

@@ -94,8 +94,8 @@ class DayFragment : Fragment() {
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
.create().apply { .create().apply {
activity?.setupDialogStuff(view, this) activity?.setupDialogStuff(view, this)
} }
} }
private fun positivePressed(dateTime: DateTime, datePicker: DatePicker) { private fun positivePressed(dateTime: DateTime, datePicker: DatePicker) {
@@ -123,7 +123,7 @@ class DayFragment : Fragment() {
lastHash = newHash lastHash = newHash
val replaceDescription = context!!.config.replaceDescription val replaceDescription = context!!.config.replaceDescription
val sorted = ArrayList<Event>(filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { val sorted = ArrayList<Event>(filtered.sortedWith(compareBy({ !it.getIsAllDay() }, { it.startTS }, { it.endTS }, { it.title }, {
if (replaceDescription) it.location else it.description if (replaceDescription) it.location else it.description
}))) })))

View File

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

View File

@@ -87,13 +87,14 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
day.dayEvents.forEach { day.dayEvents.forEach {
val event = it val event = it
if (allEvents.firstOrNull { it.id == event.id } == null) { if (allEvents.firstOrNull { it.id == event.id } == null) {
val monthViewEvent = MonthViewEvent(event.id, event.title, event.startTS, event.color, day.indexOnMonthView, getEventLastingDaysCount(event), day.indexOnMonthView) val monthViewEvent = MonthViewEvent(event.id, event.title, event.startTS, event.color, day.indexOnMonthView,
getEventLastingDaysCount(event), day.indexOnMonthView, event.getIsAllDay())
allEvents.add(monthViewEvent) allEvents.add(monthViewEvent)
} }
} }
} }
allEvents = allEvents.sortedWith(compareBy({ -it.daysCnt }, { it.startTS }, { it.startDayIndex }, { it.title })).toMutableList() as ArrayList<MonthViewEvent> allEvents = allEvents.sortedWith(compareBy({ -it.daysCnt }, { !it.isAllDay }, { it.startTS }, { it.startDayIndex }, { it.title })).toMutableList() as ArrayList<MonthViewEvent>
invalidate() invalidate()
} }