fix some glitches related to setting caldav synced default event types

This commit is contained in:
tibbi 2019-02-13 16:56:32 +01:00
parent d92ba3b9c4
commit 45d5cc3621
1 changed files with 10 additions and 2 deletions

View File

@ -199,6 +199,7 @@ class SettingsActivity : SimpleActivity() {
calDAVHelper.deleteCalDAVCalendarEvents(it.toLong()) calDAVHelper.deleteCalDAVCalendarEvents(it.toLong())
} }
eventTypesDB.deleteEventTypesWithCalendarId(config.getSyncedCalendarIdsAsList()) eventTypesDB.deleteEventTypesWithCalendarId(config.getSyncedCalendarIdsAsList())
updateDefaultEventTypeText()
}.start() }.start()
} }
} }
@ -250,6 +251,7 @@ class SettingsActivity : SimpleActivity() {
} }
eventTypesDB.deleteEventTypesWithCalendarId(removedCalendarIds) eventTypesDB.deleteEventTypesWithCalendarId(removedCalendarIds)
updateDefaultEventTypeText()
}.start() }.start()
} }
} }
@ -615,7 +617,7 @@ class SettingsActivity : SimpleActivity() {
updateDefaultEventTypeText() updateDefaultEventTypeText()
settings_default_event_type.text = getString(R.string.last_used_one) settings_default_event_type.text = getString(R.string.last_used_one)
settings_default_event_type_holder.setOnClickListener { settings_default_event_type_holder.setOnClickListener {
SelectEventTypeDialog(this, config.defaultEventTypeId, false, false, true) { SelectEventTypeDialog(this, config.defaultEventTypeId, true, false, true) {
config.defaultEventTypeId = it.id!! config.defaultEventTypeId = it.id!!
updateDefaultEventTypeText() updateDefaultEventTypeText()
} }
@ -624,14 +626,20 @@ class SettingsActivity : SimpleActivity() {
private fun updateDefaultEventTypeText() { private fun updateDefaultEventTypeText() {
if (config.defaultEventTypeId == -1L) { if (config.defaultEventTypeId == -1L) {
settings_default_event_type.text = getString(R.string.last_used_one) runOnUiThread {
settings_default_event_type.text = getString(R.string.last_used_one)
}
} else { } else {
Thread { Thread {
val eventType = eventTypesDB.getEventTypeWithId(config.defaultEventTypeId) val eventType = eventTypesDB.getEventTypeWithId(config.defaultEventTypeId)
if (eventType != null) { if (eventType != null) {
config.lastUsedCaldavCalendarId = eventType.caldavCalendarId
runOnUiThread { runOnUiThread {
settings_default_event_type.text = eventType.title settings_default_event_type.text = eventType.title
} }
} else {
config.defaultEventTypeId = -1
updateDefaultEventTypeText()
} }
}.start() }.start()
} }