move some FilterEventTypesDialog things on a background thread

This commit is contained in:
tibbi 2018-11-12 20:30:13 +01:00
parent 4f5a2de20e
commit 717f103b59

View File

@ -10,13 +10,14 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_filter_event_types.view.* import kotlinx.android.synthetic.main.dialog_filter_event_types.view.*
class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> Unit) { class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> Unit) {
var dialog: AlertDialog private lateinit var dialog: AlertDialog
val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null) private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null)
init { init {
val eventTypes = activity.dbHelper.getEventTypesSync() activity.dbHelper.getEventTypes {
val displayEventTypes = activity.config.displayEventTypes val displayEventTypes = activity.config.displayEventTypes
view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, eventTypes, displayEventTypes) activity.runOnUiThread {
view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, it, displayEventTypes)
dialog = AlertDialog.Builder(activity) dialog = AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() } .setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() }
@ -25,6 +26,8 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U
activity.setupDialogStuff(view, this, R.string.filter_events_by_type) activity.setupDialogStuff(view, this, R.string.filter_events_by_type)
} }
} }
}
}
private fun confirmEventTypes() { private fun confirmEventTypes() {
val selectedItems = (view.filter_event_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet() val selectedItems = (view.filter_event_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsSet()