fix showing repeatable events on the monthly view
This commit is contained in:
parent
aa14d3022d
commit
e6568beb32
|
@ -94,13 +94,15 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
|||
|
||||
var currDay = startDateTime
|
||||
var dayCode = Formatter.getDayCodeFromDateTime(currDay)
|
||||
var currDayEvents = (dayEvents[dayCode] ?: ArrayList()).apply { add(it) }
|
||||
var currDayEvents = dayEvents[dayCode] ?: ArrayList()
|
||||
currDayEvents.add(it)
|
||||
dayEvents[dayCode] = currDayEvents
|
||||
|
||||
while (Formatter.getDayCodeFromDateTime(currDay) != endCode) {
|
||||
currDay = currDay.plusDays(1)
|
||||
dayCode = Formatter.getDayCodeFromDateTime(currDay)
|
||||
currDayEvents = (dayEvents[dayCode] ?: ArrayList()).apply { add(it) }
|
||||
currDayEvents = dayEvents[dayCode] ?: ArrayList()
|
||||
currDayEvents.add(it)
|
||||
dayEvents[dayCode] = currDayEvents
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,11 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
val day = it
|
||||
day.dayEvents.forEach {
|
||||
val event = it
|
||||
if (allEvents.firstOrNull { it.id == event.id } == null) {
|
||||
val lastEvent = allEvents.lastOrNull { it.id == event.id }
|
||||
val daysCnt = getEventLastingDaysCount(event)
|
||||
if (lastEvent == null || lastEvent.startDayIndex + daysCnt < day.indexOnMonthView) {
|
||||
val monthViewEvent = MonthViewEvent(event.id, event.title, event.startTS, event.color, day.indexOnMonthView,
|
||||
getEventLastingDaysCount(event), day.indexOnMonthView, event.getIsAllDay())
|
||||
daysCnt, day.indexOnMonthView, event.getIsAllDay())
|
||||
allEvents.add(monthViewEvent)
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +186,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
|
|||
bgRectF.set(bgLeft, bgTop, bgRight, bgBottom)
|
||||
canvas.drawRoundRect(bgRectF, BG_CORNER_RADIUS, BG_CORNER_RADIUS, getEventBackgroundColor(event, startDayIndex, endDayIndex))
|
||||
|
||||
drawEventTitle(event.title, canvas, xPos, yPos + verticalOffset, bgRight - bgLeft, event.color, startDayIndex, endDayIndex)
|
||||
drawEventTitle(event.title, canvas, xPos, yPos + verticalOffset, bgRight - bgLeft - smallPadding, event.color, startDayIndex, endDayIndex)
|
||||
|
||||
for (i in 0 until Math.min(event.daysCnt, 7 - event.startDayIndex % 7)) {
|
||||
dayEventsCount.put(event.startDayIndex + i, dayEventsCount[event.startDayIndex + i] + 1)
|
||||
|
|
Loading…
Reference in New Issue