Don't show events that end at 00:00 as multi day event

This commit is contained in:
Wagubi Brian 2019-06-24 15:21:48 +03:00
parent 092bdaf2c2
commit a115f7774c
2 changed files with 15 additions and 3 deletions

View file

@ -420,7 +420,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
return
}
val daysCnt = Days.daysBetween(Formatter.getDateTimeFromTS(minTS).toLocalDate(), Formatter.getDateTimeFromTS(maxTS).toLocalDate()).days
//Check if End time for event is start time for another day
val isStartTimeDay = Formatter.getDateTimeFromTS(maxTS) == Formatter.getDateTimeFromTS(maxTS).withTimeAtStartOfDay()
val numDays = Days.daysBetween(Formatter.getDateTimeFromTS(minTS).toLocalDate(), Formatter.getDateTimeFromTS(maxTS).toLocalDate()).days
val daysCnt = if (numDays == 1 && isStartTimeDay) 0 else numDays
val startDateTimeInWeek = Formatter.getDateTimeFromTS(minTS)
val firstDayIndex = (startDateTimeInWeek.dayOfWeek - if (mConfig.isSundayFirst) 0 else 1) % 7

View file

@ -105,7 +105,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
// make sure we properly handle events lasting multiple days and repeating ones
val lastEvent = allEvents.lastOrNull { it.id == event.id }
val daysCnt = getEventLastingDaysCount(event)
if (lastEvent == null || lastEvent.startDayIndex + daysCnt <= day.indexOnMonthView) {
val validDayEvent = isDayValid(event, day.code)
if ((lastEvent == null || lastEvent.startDayIndex + daysCnt <= day.indexOnMonthView) && !validDayEvent) {
val monthViewEvent = MonthViewEvent(event.id!!, event.title, event.startTS, event.color, day.indexOnMonthView,
daysCnt, day.indexOnMonthView, event.getIsAllDay(), event.isPastEvent)
allEvents.add(monthViewEvent)
@ -336,6 +337,14 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con
if (diff < 0) {
eventStartDateTime = screenStartDateTime
}
return Days.daysBetween(eventStartDateTime, eventEndDateTime).days + 1
val isMidnight = Formatter.getDateTimeFromTS(endDateTime.seconds()) == Formatter.getDateTimeFromTS(endDateTime.seconds()).withTimeAtStartOfDay()
val numDays = Days.daysBetween(eventStartDateTime, eventEndDateTime).days
val daysCnt = if (numDays == 1 && isMidnight) 0 else numDays
return daysCnt + 1
}
private fun isDayValid(event: Event, code: String): Boolean {
val date = Formatter.getDateTimeFromCode(code)
return Formatter.getDateTimeFromTS(event.endTS) == Formatter.getDateTimeFromTS(date.seconds()).withTimeAtStartOfDay()
}
}