From 8783b674a789dd9e2ccc512d853e23a92d300d96 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 11 Feb 2017 21:14:02 +0100 Subject: [PATCH] reset event type to regular at deleting an events type --- .../simplemobiletools/calendar/helpers/DBHelper.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index 565951435..fb3d3809e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -263,11 +263,24 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont if (deleteIds.isEmpty()) return + for (eventTypeId in deleteIds) { + resetEventsWithType(eventTypeId) + } + val args = TextUtils.join(", ", deleteIds) val selection = "$COL_TYPE_ID IN ($args)" callback.invoke(mDb.delete(TYPES_TABLE_NAME, selection, null)) } + private fun resetEventsWithType(eventTypeId: Int) { + val values = ContentValues() + values.put(COL_EVENT_TYPE, REGULAR_EVENT_ID) + + val selection = "$COL_EVENT_TYPE = ?" + val selectionArgs = arrayOf(eventTypeId.toString()) + mDb.update(MAIN_TABLE_NAME, values, selection, selectionArgs) + } + fun getImportIds(): ArrayList { val ids = ArrayList() val columns = arrayOf(COL_IMPORT_ID)