From e5a23c74d14e132beda9b67c3db08eccd5b913e7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 9 Oct 2017 08:46:56 +0200 Subject: [PATCH] addig a null check --- .../calendar/helpers/CalDAVHandler.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt index 0bc712555..ca8fda07c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt @@ -25,17 +25,17 @@ import kotlin.collections.ArrayList class CalDAVHandler(val context: Context) { fun refreshCalendars(activity: SimpleActivity? = null, callback: () -> Unit) { val dbHelper = context.dbHelper - getCalDAVCalendars(activity, context.config.caldavSyncedCalendarIDs).forEach { - val localEventType = dbHelper.getEventTypeWithCalDAVCalendarId(it.id) - localEventType?.apply { - title = it.displayName - caldavDisplayName = it.displayName - caldavEmail = it.accountName - color = it.color + for (calendar in getCalDAVCalendars(activity, context.config.caldavSyncedCalendarIDs)) { + val localEventType = dbHelper.getEventTypeWithCalDAVCalendarId(calendar.id) ?: continue + localEventType.apply { + title = calendar.displayName + caldavDisplayName = calendar.displayName + caldavEmail = calendar.accountName + color = calendar.color dbHelper.updateLocalEventType(this) } - CalDAVHandler(context).fetchCalDAVCalendarEvents(it.id, localEventType!!.id, activity) + CalDAVHandler(context).fetchCalDAVCalendarEvents(calendar.id, localEventType.id, activity) } context.scheduleCalDAVSync(true) callback()