diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index a7299e313..09eaa4f9d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -683,12 +683,16 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont fun getEvents(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: ArrayList) -> Unit) { Thread { - getEventsInBackground(fromTS, toTS, eventId, callback) + getEventsInBackground(fromTS = fromTS, toTS = toTS, eventId = eventId, callback = callback) }.start() } - fun getEventsInBackground(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: ArrayList) -> Unit) { - val events = ArrayList() + fun getEventsInBackground(fromTS: Int, + toTS: Int, + eventId: Int = -1, + filterEventType: Boolean = false, + callback: (events: ArrayList) -> Unit) { + var events = ArrayList() var selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL AND $COL_START_TS != 0" if (eventId != -1) @@ -701,8 +705,17 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont events.addAll(getAllDayEvents(fromTS, eventId)) - val filtered = events.distinct().filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) } as ArrayList - callback(filtered) + val displayEventTypes = context.config.displayEventTypes + if (filterEventType) { + events = events.filter { + displayEventTypes.contains(it.toString()) + } as ArrayList + } + + events = events + .distinct() + .filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) } as ArrayList + callback(events) } fun getRepeatableEventsFor(fromTS: Int, toTS: Int, eventId: Int = -1): List {