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 888fd503b..55a561460 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 @@ -145,7 +145,12 @@ class CalDAVHelper(val context: Context) { private fun fetchCalDAVCalendarEvents(calendarId: Int, eventTypeId: Long, showToasts: Boolean) { val importIdsMap = HashMap() val fetchedEventIds = ArrayList() - val existingEvents = context.eventsDB.getEventsFromCalDAVCalendar("$CALDAV-$calendarId") + val existingEvents = try { + context.eventsDB.getEventsFromCalDAVCalendar("$CALDAV-$calendarId") + } catch (e: Exception) { + ArrayList() + } + existingEvents.forEach { importIdsMap[it.importId] = it } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Converters.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Converters.kt index 45de469a6..2cc0777b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Converters.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Converters.kt @@ -16,7 +16,11 @@ class Converters { value } - return gson.fromJson(newValue, stringType) + return try { + gson.fromJson(newValue, stringType) + } catch (e: Exception) { + ArrayList() + } } @TypeConverter diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt index fbfd5821f..c119e8928 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt @@ -248,7 +248,11 @@ class EventsHelper(val context: Context) { callback(ArrayList()) return } else { - eventsDB.getOneTimeEventsFromToWithTypes(toTS, fromTS, context.config.getDisplayEventTypessAsList()).toMutableList() as ArrayList + try { + eventsDB.getOneTimeEventsFromToWithTypes(toTS, fromTS, context.config.getDisplayEventTypessAsList()).toMutableList() as ArrayList + } catch (e: Exception) { + ArrayList() + } } } else { if (eventId == -1L) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt index ecedb5f91..c61a6b37d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt @@ -86,7 +86,11 @@ data class Event( while (newDateTime.dayOfMonth().maximumValue < Formatter.getDateTimeFromTS(original.startTS).dayOfMonth().maximumValue) { newDateTime = newDateTime.plusMonths(repeatInterval / MONTH) - newDateTime = newDateTime.withDayOfMonth(currStart.dayOfMonth) + newDateTime = try { + newDateTime.withDayOfMonth(currStart.dayOfMonth) + } catch (e: Exception) { + newDateTime + } } return newDateTime }