mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-26 16:37:46 +01:00
moving event deleting on a background thread in some cases
This commit is contained in:
parent
ab10394122
commit
fab72371d0
@ -677,12 +677,16 @@ class EventActivity : SimpleActivity() {
|
||||
|
||||
private fun deleteEvent() {
|
||||
DeleteEventDialog(this, arrayListOf(mEvent.id!!), mEvent.repeatInterval > 0) {
|
||||
when (it) {
|
||||
DELETE_SELECTED_OCCURRENCE -> dbHelper.addEventRepeatException(mEvent.id!!, mEventOccurrenceTS, true)
|
||||
DELETE_FUTURE_OCCURRENCES -> dbHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
|
||||
DELETE_ALL_OCCURRENCES -> dbHelper.deleteEvents(arrayOf(mEvent.id.toString()), true)
|
||||
}
|
||||
finish()
|
||||
Thread {
|
||||
when (it) {
|
||||
DELETE_SELECTED_OCCURRENCE -> dbHelper.addEventRepeatException(mEvent.id!!, mEventOccurrenceTS, true)
|
||||
DELETE_FUTURE_OCCURRENCES -> dbHelper.addEventRepeatLimit(mEvent.id!!, mEventOccurrenceTS)
|
||||
DELETE_ALL_OCCURRENCES -> dbHelper.deleteEvents(arrayOf(mEvent.id.toString()), true)
|
||||
}
|
||||
runOnUiThread {
|
||||
finish()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,12 +142,16 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
||||
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) { it ->
|
||||
events.removeAll(eventsToDelete)
|
||||
|
||||
val nonRepeatingEventIDs = eventsToDelete.asSequence().filter { it.repeatInterval == 0 }.map { it.id.toString() }.toList().toTypedArray()
|
||||
activity.dbHelper.deleteEvents(nonRepeatingEventIDs, true)
|
||||
Thread {
|
||||
val nonRepeatingEventIDs = eventsToDelete.asSequence().filter { it.repeatInterval == 0 }.map { it.id.toString() }.toList().toTypedArray()
|
||||
activity.dbHelper.deleteEvents(nonRepeatingEventIDs, true)
|
||||
|
||||
val repeatingEventIDs = eventsToDelete.asSequence().filter { it.repeatInterval != 0 }.map { it.id!! }.toList()
|
||||
activity.handleEventDeleting(repeatingEventIDs, timestamps, it)
|
||||
removeSelectedItems(positions)
|
||||
val repeatingEventIDs = eventsToDelete.asSequence().filter { it.repeatInterval != 0 }.map { it.id!! }.toList()
|
||||
activity.handleEventDeleting(repeatingEventIDs, timestamps, it)
|
||||
activity.runOnUiThread {
|
||||
removeSelectedItems(positions)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,13 +206,17 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
|
||||
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) {
|
||||
listItems.removeAll(eventsToDelete)
|
||||
|
||||
val nonRepeatingEventIDs = eventsToDelete.filter { !it.isRepeatable }.map { it.id.toString() }.toTypedArray()
|
||||
activity.dbHelper.deleteEvents(nonRepeatingEventIDs, true)
|
||||
Thread {
|
||||
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 }
|
||||
activity.handleEventDeleting(repeatingEventIDs, timestamps, it)
|
||||
listener?.refreshItems()
|
||||
finishActMode()
|
||||
val repeatingEventIDs = eventsToDelete.filter { it.isRepeatable }.map { it.id }
|
||||
activity.handleEventDeleting(repeatingEventIDs, timestamps, it)
|
||||
activity.runOnUiThread {
|
||||
listener?.refreshItems()
|
||||
finishActMode()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user