diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt index 16341a4ae..d9f130c4d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -130,8 +130,8 @@ class IcsImporter { } private fun getTimestamp(fullString: String): Int { - try { - return if (fullString.startsWith(';')) { + return try { + if (fullString.startsWith(';')) { val value = fullString.substring(fullString.lastIndexOf(':') + 1) if (!value.contains("T")) curFlags = curFlags or FLAG_ALL_DAY @@ -142,7 +142,7 @@ class IcsImporter { } } catch (e: Exception) { eventsFailed++ - return -1 + -1 } } @@ -154,11 +154,11 @@ class IcsImporter { } val eventId = context.dbHelper.getEventTypeIdWithTitle(eventTypeTitle) - if (eventId == -1) { + curEventType = if (eventId == -1) { val eventType = EventType(0, eventTypeTitle, context.resources.getColor(R.color.color_primary)) - curEventType = context.dbHelper.insertEventType(eventType) + context.dbHelper.insertEventType(eventType) } else { - curEventType = eventId + eventId } } @@ -177,8 +177,8 @@ class IcsImporter { curDescription = "" curImportId = "" curFlags = 0 - curReminderMinutes = ArrayList() - curRepeatExceptions = ArrayList() + curReminderMinutes = ArrayList() + curRepeatExceptions = ArrayList() curRepeatInterval = 0 curRepeatLimit = 0 curRepeatRule = 0 diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt index 250b9e6cd..644a54946 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -112,5 +112,5 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var } } - fun getCalDAVCalendarId() = if (source.contains("-")) (source.split("-").lastOrNull() ?: "0").toString().toInt() else 0 + fun getCalDAVCalendarId() = if (source.contains("-") && source != SOURCE_IMPORTED_ICS) (source.split("-").lastOrNull() ?: "0").toString().toInt() else 0 }