mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 12:20:51 +01:00
properly delete non recurring events when selected together with recurring
This commit is contained in:
parent
2133365be4
commit
11b97500ed
@ -122,19 +122,23 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||||||
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) {
|
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) {
|
||||||
events.removeAll(eventsToDelete)
|
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) {
|
when (it) {
|
||||||
DELETE_SELECTED_OCCURRENCE -> {
|
DELETE_SELECTED_OCCURRENCE -> {
|
||||||
eventIds.forEachIndexed { index, value ->
|
repeatingEventIDs.forEachIndexed { index, value ->
|
||||||
activity.dbHelper.addEventRepeatException(value, timestamps[index], true)
|
activity.dbHelper.addEventRepeatException(value, timestamps[index], true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DELETE_FUTURE_OCCURRENCES -> {
|
DELETE_FUTURE_OCCURRENCES -> {
|
||||||
eventIds.forEachIndexed { index, value ->
|
repeatingEventIDs.forEachIndexed { index, value ->
|
||||||
activity.dbHelper.addEventRepeatLimit(value, timestamps[index])
|
activity.dbHelper.addEventRepeatLimit(value, timestamps[index])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DELETE_ALL_OCCURRENCES -> {
|
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)
|
activity.dbHelper.deleteEvents(eventIDs, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,19 +216,23 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
|
|||||||
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) {
|
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) {
|
||||||
listItems.removeAll(eventsToDelete)
|
listItems.removeAll(eventsToDelete)
|
||||||
|
|
||||||
|
val nonRepeatingEventIDs = eventsToDelete.filter { !it.isRepeatable }.map { it.id.toString() }.toTypedArray()
|
||||||
|
activity.dbHelper.deleteEvents(nonRepeatingEventIDs, true)
|
||||||
|
|
||||||
|
val repeatingEventIDs = eventsToDelete.filter { it.isRepeatable }.map { it.id }
|
||||||
when (it) {
|
when (it) {
|
||||||
DELETE_SELECTED_OCCURRENCE -> {
|
DELETE_SELECTED_OCCURRENCE -> {
|
||||||
eventIds.forEachIndexed { index, value ->
|
repeatingEventIDs.forEachIndexed { index, value ->
|
||||||
activity.dbHelper.addEventRepeatException(value, timestamps[index], true)
|
activity.dbHelper.addEventRepeatException(value, timestamps[index], true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DELETE_FUTURE_OCCURRENCES -> {
|
DELETE_FUTURE_OCCURRENCES -> {
|
||||||
eventIds.forEachIndexed { index, value ->
|
repeatingEventIDs.forEachIndexed { index, value ->
|
||||||
activity.dbHelper.addEventRepeatLimit(value, timestamps[index])
|
activity.dbHelper.addEventRepeatLimit(value, timestamps[index])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DELETE_ALL_OCCURRENCES -> {
|
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)
|
activity.dbHelper.deleteEvents(eventIDs, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user