if an ics file event contains multiple categories, use the first one

This commit is contained in:
tibbi 2017-03-05 21:59:31 +01:00
parent 6d93a7def5
commit da75540321
1 changed files with 13 additions and 10 deletions

View File

@ -155,16 +155,19 @@ class IcsParser {
}
private fun tryAddCategories(categories: String, context: Context) {
if (!categories.contains(",")) {
val eventTitle = categories
val dbHelper = DBHelper.newInstance(context)
val eventId = dbHelper.getEventTypeIdWithTitle(eventTitle)
if (eventId == -1) {
val eventType = EventType(0, eventTitle, context.resources.getColor(R.color.color_primary))
curEventType = dbHelper.insertEventType(eventType)
} else {
curEventType = eventId
}
val eventTypeTitle = if (categories.contains(",")) {
categories.split(",")[0]
} else {
categories
}
val dbHelper = DBHelper.newInstance(context)
val eventId = dbHelper.getEventTypeIdWithTitle(eventTypeTitle)
if (eventId == -1) {
val eventType = EventType(0, eventTypeTitle, context.resources.getColor(R.color.color_primary))
curEventType = dbHelper.insertEventType(eventType)
} else {
curEventType = eventId
}
}