make event update callback nullable

This commit is contained in:
tibbi
2018-01-10 21:00:32 +01:00
parent 7fb3a95455
commit 30ee706176
3 changed files with 4 additions and 5 deletions

View File

@@ -253,8 +253,7 @@ class CalDAVHandler(val context: Context) {
existingEvent.id = 0 existingEvent.id = 0
if (existingEvent.hashCode() != event.hashCode() && title.isNotEmpty()) { if (existingEvent.hashCode() != event.hashCode() && title.isNotEmpty()) {
event.id = originalEventId event.id = originalEventId
context.dbHelper.update(event, false) { context.dbHelper.update(event, false)
}
} }
} else { } else {
// if the event is an exception from another events repeat rule, find the original parent event // if the event is an exception from another events repeat rule, find the original parent event

View File

@@ -226,7 +226,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
callback(event.id) callback(event.id)
} }
fun update(event: Event, updateAtCalDAV: Boolean, callback: () -> Unit) { fun update(event: Event, updateAtCalDAV: Boolean, callback: (() -> Unit)? = null) {
val selectionArgs = arrayOf(event.id.toString()) val selectionArgs = arrayOf(event.id.toString())
val values = fillEventValues(event) val values = fillEventValues(event)
val selection = "$COL_ID = ?" val selection = "$COL_ID = ?"
@@ -245,7 +245,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
if (updateAtCalDAV && event.source != SOURCE_SIMPLE_CALENDAR && context.config.caldavSync) { if (updateAtCalDAV && event.source != SOURCE_SIMPLE_CALENDAR && context.config.caldavSync) {
CalDAVHandler(context).updateCalDAVEvent(event) CalDAVHandler(context).updateCalDAVEvent(event)
} }
callback() callback?.invoke()
} }
private fun fillEventValues(event: Event): ContentValues { private fun fillEventValues(event: Event): ContentValues {

View File

@@ -140,7 +140,7 @@ class IcsImporter(val activity: SimpleActivity) {
} }
} else { } else {
event.id = eventToUpdate.id event.id = eventToUpdate.id
activity.dbHelper.update(event, true) {} activity.dbHelper.update(event, true)
} }
eventsImported++ eventsImported++
resetValues() resetValues()