update caldav calendar data at refreshing events too

This commit is contained in:
tibbi 2017-08-23 22:22:29 +02:00
parent c88ccbe83f
commit c1a59f36a7
2 changed files with 14 additions and 2 deletions

View File

@ -22,8 +22,20 @@ import kotlin.collections.ArrayList
class CalDAVHandler(val context: Context) {
fun refreshCalendars(callback: () -> Unit) {
val dbHelper = context.dbHelper
getCalDAVCalendars(context.config.caldavSyncedCalendarIDs).forEach {
val eventTypeId = context.dbHelper.getEventTypeIdWithTitle(it.getFullTitle())
val localEventTypeId = dbHelper.getEventTypeIdWithCalDAVCalendarId(it.id)
if (localEventTypeId != -1) {
dbHelper.getEventType(localEventTypeId)?.apply {
title = it.displayName
caldavDisplayName = it.displayName
caldavEmail = it.accountName
color = it.color
dbHelper.updateLocalEventType(this)
}
}
val eventTypeId = dbHelper.getEventTypeIdWithTitle(it.getFullTitle())
CalDAVHandler(context).fetchCalDAVCalendarEvents(it.id, eventTypeId)
}
context.scheduleCalDAVSync(true)

View File

@ -289,7 +289,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
}
}
private fun updateLocalEventType(eventType: EventType): Int {
fun updateLocalEventType(eventType: EventType): Int {
val selectionArgs = arrayOf(eventType.id.toString())
val values = fillEventTypeValues(eventType)
val selection = "$COL_TYPE_ID = ?"