From 717f103b5974b832cb85af6069a5181cdd96892e Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 12 Nov 2018 20:30:13 +0100 Subject: [PATCH] move some FilterEventTypesDialog things on a background thread --- .../pro/dialogs/FilterEventTypesDialog.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/FilterEventTypesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/FilterEventTypesDialog.kt index 5af9b9c26..60f21fc91 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/FilterEventTypesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/FilterEventTypesDialog.kt @@ -10,20 +10,23 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff import kotlinx.android.synthetic.main.dialog_filter_event_types.view.* class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> Unit) { - var dialog: AlertDialog - val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null) + private lateinit var dialog: AlertDialog + private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null) init { - val eventTypes = activity.dbHelper.getEventTypesSync() - val displayEventTypes = activity.config.displayEventTypes - view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, eventTypes, displayEventTypes) + activity.dbHelper.getEventTypes { + val displayEventTypes = activity.config.displayEventTypes + activity.runOnUiThread { + view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, it, displayEventTypes) - dialog = AlertDialog.Builder(activity) - .setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() } - .setNegativeButton(R.string.cancel, null) - .create().apply { - activity.setupDialogStuff(view, this, R.string.filter_events_by_type) - } + dialog = AlertDialog.Builder(activity) + .setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() } + .setNegativeButton(R.string.cancel, null) + .create().apply { + activity.setupDialogStuff(view, this, R.string.filter_events_by_type) + } + } + } } private fun confirmEventTypes() {