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,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() {