moving getCalDAVCalendarEvents to Room

This commit is contained in:
tibbi 2018-11-14 22:07:54 +01:00
parent 5b466ec841
commit 86a4b3fdb1
3 changed files with 4 additions and 9 deletions

View file

@ -356,8 +356,7 @@ class CalDAVHandler(val context: Context) {
}
fun deleteCalDAVCalendarEvents(calendarId: Long) {
val events = context.dbHelper.getCalDAVCalendarEvents(calendarId)
val eventIds = events.mapNotNull { it.id }.toMutableList()
val eventIds = context.eventsDB.getCalDAVCalendarEvents("$CALDAV-$calendarId").toMutableList()
EventsHelper(context).deleteEvents(eventIds, false)
}

View file

@ -90,13 +90,6 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
}
}
fun getCalDAVCalendarEvents(calendarId: Long): List<Event> {
val selection = "$MAIN_TABLE_NAME.$COL_EVENT_SOURCE = (?)"
val selectionArgs = arrayOf("$CALDAV-$calendarId")
val cursor = getEventsCursor(selection, selectionArgs)
return fillEvents(cursor).filter { it.importId.isNotEmpty() }
}
fun addEventRepeatException(parentEventId: Long, occurrenceTS: Int, addToCalDAV: Boolean, childImportId: String? = null) {
fillExceptionValues(parentEventId, occurrenceTS, addToCalDAV, childImportId) {
context.eventRepetitionExceptionsDB.insert(it)

View file

@ -40,6 +40,9 @@ interface EventsDao {
@Query("SELECT * FROM events WHERE import_id != \"\"")
fun getEventsWithImportIds(): List<Event>
@Query("SELECT id FROM events WHERE source = :source AND import_id != \"\"")
fun getCalDAVCalendarEvents(source: String): List<Long>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertOrUpdate(event: Event): Long