mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
fetch data after dialog is shown
This commit is contained in:
@ -22,17 +22,24 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
|||||||
private var isContactsReady = false
|
private var isContactsReady = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
ContactsHelper(activity).getContactSources { contactSources ->
|
dialog = AlertDialog.Builder(activity)
|
||||||
contactSources.mapTo(this.contactSources) { it.copy() }
|
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmContactSources() }
|
||||||
isContactSourcesReady = true
|
.setNegativeButton(R.string.cancel, null)
|
||||||
processDataIfReady()
|
.create().apply {
|
||||||
}
|
activity.setupDialogStuff(view, this) {
|
||||||
|
ContactsHelper(activity).getContactSources { contactSources ->
|
||||||
|
contactSources.mapTo(this@FilterContactSourcesDialog.contactSources) { it.copy() }
|
||||||
|
isContactSourcesReady = true
|
||||||
|
processDataIfReady()
|
||||||
|
}
|
||||||
|
|
||||||
ContactsHelper(activity).getContacts(getAll = true) { contacts ->
|
ContactsHelper(activity).getContacts(getAll = true) { contacts ->
|
||||||
contacts.mapTo(this.contacts) { it.copy() }
|
contacts.mapTo(this@FilterContactSourcesDialog.contacts) { it.copy() }
|
||||||
isContactsReady = true
|
isContactsReady = true
|
||||||
processDataIfReady()
|
processDataIfReady()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processDataIfReady() {
|
private fun processDataIfReady() {
|
||||||
@ -49,16 +56,9 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
|||||||
contactSources.clear()
|
contactSources.clear()
|
||||||
contactSources.addAll(contactSourcesWithCount)
|
contactSources.addAll(contactSourcesWithCount)
|
||||||
|
|
||||||
val selectedSources = activity.getVisibleContactSources()
|
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
|
val selectedSources = activity.getVisibleContactSources()
|
||||||
view.filter_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
|
view.filter_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
|
||||||
|
|
||||||
dialog = AlertDialog.Builder(activity)
|
|
||||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmContactSources() }
|
|
||||||
.setNegativeButton(R.string.cancel, null)
|
|
||||||
.create().apply {
|
|
||||||
activity.setupDialogStuff(view, this)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user