From 2622007164c7d4c142b0803c19cccdccbfbdfc3e Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 3 Apr 2019 19:46:51 +0200 Subject: [PATCH] fixing a crash related to inserting CalDAV event repetition exceptions --- .../calendar/pro/helpers/CalDAVHelper.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt index 058249827..13ff0e810 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/CalDAVHelper.kt @@ -452,12 +452,15 @@ class CalDAVHelper(val context: Context) { refreshCalDAVCalendar(event) } - fun insertEventRepeatException(event: Event, occurrenceTS: Long): Long { + fun insertEventRepeatException(event: Event, occurrenceTS: Long) { val uri = CalendarContract.Events.CONTENT_URI val values = fillEventRepeatExceptionValues(event, occurrenceTS) - val newUri = context.contentResolver.insert(uri, values) - refreshCalDAVCalendar(event) - return java.lang.Long.parseLong(newUri.lastPathSegment) + try { + context.contentResolver.insert(uri, values) + refreshCalDAVCalendar(event) + } catch (e: Exception) { + context.showErrorToast(e) + } } private fun fillEventRepeatExceptionValues(event: Event, occurrenceTS: Long): ContentValues {