catch exceptions thrown at parsing caldav event id

This commit is contained in:
tibbi 2017-08-28 16:21:26 +02:00
parent cfe4df64b1
commit 086a294184
1 changed files with 7 additions and 1 deletions

View File

@ -104,7 +104,13 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var
}
}
fun getCalDAVEventId() = if (importId.contains("-")) (importId.split("-").lastOrNull() ?: "0").toString().toLong() else 0L
fun getCalDAVEventId(): Long {
return try {
(importId.split("-").lastOrNull() ?: "0").toString().toLong()
} catch (e: NumberFormatException) {
0L
}
}
fun getCalDAVCalendarId() = if (source.contains("-")) (source.split("-").lastOrNull() ?: "0").toString().toInt() else 0
}