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) { fun deleteCalDAVCalendarEvents(calendarId: Long) {
val events = context.dbHelper.getCalDAVCalendarEvents(calendarId) val eventIds = context.eventsDB.getCalDAVCalendarEvents("$CALDAV-$calendarId").toMutableList()
val eventIds = events.mapNotNull { it.id }.toMutableList()
EventsHelper(context).deleteEvents(eventIds, false) 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) { fun addEventRepeatException(parentEventId: Long, occurrenceTS: Int, addToCalDAV: Boolean, childImportId: String? = null) {
fillExceptionValues(parentEventId, occurrenceTS, addToCalDAV, childImportId) { fillExceptionValues(parentEventId, occurrenceTS, addToCalDAV, childImportId) {
context.eventRepetitionExceptionsDB.insert(it) context.eventRepetitionExceptionsDB.insert(it)

View File

@ -40,6 +40,9 @@ interface EventsDao {
@Query("SELECT * FROM events WHERE import_id != \"\"") @Query("SELECT * FROM events WHERE import_id != \"\"")
fun getEventsWithImportIds(): List<Event> 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) @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertOrUpdate(event: Event): Long fun insertOrUpdate(event: Event): Long