moving Event storing functions on a background thread too

This commit is contained in:
tibbi
2018-11-11 23:46:44 +01:00
parent 34778bb56a
commit 6ec9792aa0

View File

@ -765,7 +765,9 @@ class EventActivity : SimpleActivity() {
mEvent.id = 0
}
storeEvent(wasRepeatable)
Thread {
storeEvent(wasRepeatable)
}.start()
}
private fun storeEvent(wasRepeatable: Boolean) {
@ -781,25 +783,8 @@ class EventActivity : SimpleActivity() {
}
} else {
if (mRepeatInterval > 0 && wasRepeatable) {
EditRepeatingEventDialog(this) {
if (it) {
dbHelper.update(mEvent, true, this) {
finish()
}
} else {
dbHelper.addEventRepeatException(mEvent.id!!, mEventOccurrenceTS, true)
mEvent.apply {
parentId = id!!.toLong()
id = null
repeatRule = 0
repeatInterval = 0
repeatLimit = 0
}
dbHelper.insert(mEvent, true, this) {
finish()
}
}
runOnUiThread {
showEditRepeatingEventDialog()
}
} else {
dbHelper.update(mEvent, true, this) {
@ -809,6 +794,29 @@ class EventActivity : SimpleActivity() {
}
}
private fun showEditRepeatingEventDialog() {
EditRepeatingEventDialog(this) {
if (it) {
dbHelper.update(mEvent, true, this) {
finish()
}
} else {
dbHelper.addEventRepeatException(mEvent.id!!, mEventOccurrenceTS, true)
mEvent.apply {
parentId = id!!.toLong()
id = null
repeatRule = 0
repeatInterval = 0
repeatLimit = 0
}
dbHelper.insert(mEvent, true, this) {
finish()
}
}
}
}
private fun updateStartTexts() {
updateStartDateText()
updateStartTimeText()