add all-day events to event list views

This commit is contained in:
tibbi 2017-06-24 14:01:31 +02:00
parent 863e342fe0
commit 14a1658b0a
1 changed files with 15 additions and 1 deletions

View File

@ -451,7 +451,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
events.addAll(getRepeatableEventsFor(fromTS, toTS, eventId))
val filtered = events.filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) } as MutableList<Event>
events.addAll(getAllDayEvents(fromTS, toTS, eventId))
val filtered = events.distinct().filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) } as MutableList<Event>
callback(filtered)
}
@ -520,6 +522,18 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
return events
}
private fun getAllDayEvents(fromTS: Int, toTS: Int, eventId: Int = -1): List<Event> {
val events = ArrayList<Event>()
var selection = "($COL_FLAGS & $FLAG_ALL_DAY) != 0"
if (eventId != -1)
selection += " AND $MAIN_TABLE_NAME.$COL_ID = $eventId"
val todayCode = Formatter.getDayCodeFromTS(fromTS)
val cursor = getEventsCursor(selection)
events.addAll(fillEvents(cursor).filter { todayCode == Formatter.getDayCodeFromTS(it.startTS) })
return events
}
// check if its the proper week, for events repeating by x weeks
private fun isOnProperWeek(event: Event, startTimes: SparseIntArray): Boolean {
val initialWeekOfYear = Formatter.getDateTimeFromTS(startTimes[event.id]).weekOfWeekyear