Properly handle events spanning midnight
This commit is contained in:
parent
ac43e14999
commit
2fe3e98695
|
@ -741,6 +741,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
val firstDayIndex = startDateTimeInWeek.dayOfMonth // indices must be unique for the visible range (2 weeks)
|
||||
val lastDayIndex = firstDayIndex + daysCnt
|
||||
val dayIndices = firstDayIndex..lastDayIndex
|
||||
val isSameDayEvent = firstDayIndex == lastDayIndex
|
||||
|
||||
var doesEventFit: Boolean
|
||||
var wasEventHandled = false
|
||||
|
@ -753,11 +754,13 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
|
||||
doesEventFit = dayIndices.all { !row.contains(it) }
|
||||
|
||||
for (dayIndex in dayIndices) {
|
||||
if (doesEventFit) {
|
||||
row.add(dayIndex)
|
||||
if (doesEventFit && isSameDayEvent) {
|
||||
row.add(firstDayIndex)
|
||||
wasEventHandled = true
|
||||
} else if (index == allDayRows.lastIndex) {
|
||||
} else {
|
||||
// handle events spanning midnight
|
||||
for (dayIndex in dayIndices) {
|
||||
if (index == allDayRows.lastIndex) {
|
||||
allDayRows.add(HashSet())
|
||||
addNewLine()
|
||||
drawAtLine++
|
||||
|
@ -765,6 +768,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
|||
allDayRows.last().add(dayIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wasEventHandled) {
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue