fixing a couple more threading issues

This commit is contained in:
tibbi 2018-11-12 18:35:55 +01:00
parent 9e06f1f338
commit d0055239bd
2 changed files with 28 additions and 18 deletions

View File

@ -167,7 +167,7 @@ class EventActivity : SimpleActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.save -> saveEvent()
R.id.save -> saveCurrentEvent()
R.id.delete -> deleteEvent()
R.id.duplicate -> duplicateEvent()
R.id.share -> shareEvent()
@ -647,17 +647,21 @@ class EventActivity : SimpleActivity() {
} else {
event_caldav_calendar_email.text = currentCalendar.accountName
val calendarColor = dbHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)?.color ?: currentCalendar.color
event_caldav_calendar_color.setFillWithStroke(calendarColor, config.backgroundColor)
Thread {
val calendarColor = dbHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)?.color ?: currentCalendar.color
runOnUiThread {
event_caldav_calendar_color.setFillWithStroke(calendarColor, config.backgroundColor)
event_caldav_calendar_name.apply {
text = currentCalendar.displayName
setPadding(paddingLeft, paddingTop, paddingRight, resources.getDimension(R.dimen.tiny_margin).toInt())
}
event_caldav_calendar_name.apply {
text = currentCalendar.displayName
setPadding(paddingLeft, paddingTop, paddingRight, resources.getDimension(R.dimen.tiny_margin).toInt())
}
event_caldav_calendar_holder.apply {
setPadding(paddingLeft, 0, paddingRight, 0)
}
event_caldav_calendar_holder.apply {
setPadding(paddingLeft, 0, paddingRight, 0)
}
}
}.start()
}
}
@ -692,6 +696,12 @@ class EventActivity : SimpleActivity() {
finish()
}
private fun saveCurrentEvent() {
Thread {
saveEvent()
}.start()
}
private fun saveEvent() {
val newTitle = event_title.value
if (newTitle.isEmpty()) {
@ -765,9 +775,7 @@ class EventActivity : SimpleActivity() {
mEvent.id = 0
}
Thread {
storeEvent(wasRepeatable)
}.start()
storeEvent(wasRepeatable)
}
private fun storeEvent(wasRepeatable: Boolean) {

View File

@ -27,13 +27,15 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD
radioGroup = view.dialog_radio_group
activity.dbHelper.getEventTypes {
calendars.forEach {
val localEventType = activity.dbHelper.getEventTypeWithCalDAVCalendarId(it.id)
if (localEventType != null) {
it.color = localEventType.color
}
}
activity.runOnUiThread {
calendars.forEach {
val localEventType = activity.dbHelper.getEventTypeWithCalDAVCalendarId(it.id)
if (localEventType != null) {
it.color = localEventType.color
}
addRadioButton(it.getFullTitle(), it.id, it.color)
}
addRadioButton(activity.getString(R.string.store_locally_only), STORED_LOCALLY_ONLY, Color.TRANSPARENT)