diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt index dec21ffb4..d3172088d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt @@ -122,19 +122,23 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r DeleteEventDialog(activity, eventIds, hasRepeatableEvent) { events.removeAll(eventsToDelete) + val nonRepeatingEventIDs = eventsToDelete.filter { it.repeatInterval == 0 }.map { it.id.toString() }.toTypedArray() + activity.dbHelper.deleteEvents(nonRepeatingEventIDs, true) + + val repeatingEventIDs = eventsToDelete.filter { it.repeatInterval != 0 }.map { it.id } when (it) { DELETE_SELECTED_OCCURRENCE -> { - eventIds.forEachIndexed { index, value -> + repeatingEventIDs.forEachIndexed { index, value -> activity.dbHelper.addEventRepeatException(value, timestamps[index], true) } } DELETE_FUTURE_OCCURRENCES -> { - eventIds.forEachIndexed { index, value -> + repeatingEventIDs.forEachIndexed { index, value -> activity.dbHelper.addEventRepeatLimit(value, timestamps[index]) } } DELETE_ALL_OCCURRENCES -> { - val eventIDs = Array(eventIds.size, { i -> (eventIds[i].toString()) }) + val eventIDs = Array(repeatingEventIDs.size, { i -> (repeatingEventIDs[i].toString()) }) activity.dbHelper.deleteEvents(eventIDs, true) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt index a66019a10..184a20ac8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt @@ -216,19 +216,23 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList { - eventIds.forEachIndexed { index, value -> + repeatingEventIDs.forEachIndexed { index, value -> activity.dbHelper.addEventRepeatException(value, timestamps[index], true) } } DELETE_FUTURE_OCCURRENCES -> { - eventIds.forEachIndexed { index, value -> + repeatingEventIDs.forEachIndexed { index, value -> activity.dbHelper.addEventRepeatLimit(value, timestamps[index]) } } DELETE_ALL_OCCURRENCES -> { - val eventIDs = Array(eventIds.size, { i -> (eventIds[i].toString()) }) + val eventIDs = Array(repeatingEventIDs.size, { i -> (repeatingEventIDs[i].toString()) }) activity.dbHelper.deleteEvents(eventIDs, true) } }