mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
add the contact count dynamically
This commit is contained in:
@ -22,11 +22,6 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
|||||||
private var isContactsReady = false
|
private var isContactsReady = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
dialog = AlertDialog.Builder(activity)
|
|
||||||
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmContactSources() }
|
|
||||||
.setNegativeButton(R.string.cancel, null)
|
|
||||||
.create().apply {
|
|
||||||
activity.setupDialogStuff(view, this) {
|
|
||||||
ContactsHelper(activity).getContactSources { contactSources ->
|
ContactsHelper(activity).getContactSources { contactSources ->
|
||||||
contactSources.mapTo(this@FilterContactSourcesDialog.contactSources) { it.copy() }
|
contactSources.mapTo(this@FilterContactSourcesDialog.contactSources) { it.copy() }
|
||||||
isContactSourcesReady = true
|
isContactSourcesReady = true
|
||||||
@ -39,11 +34,9 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
|||||||
processDataIfReady()
|
processDataIfReady()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun processDataIfReady() {
|
private fun processDataIfReady() {
|
||||||
if (!isContactSourcesReady || !isContactsReady) {
|
if (!isContactSourcesReady) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +52,15 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
|
|||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
val selectedSources = activity.getVisibleContactSources()
|
val selectedSources = activity.getVisibleContactSources()
|
||||||
view.filter_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
|
view.filter_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
|
||||||
|
|
||||||
|
if (dialog == null) {
|
||||||
|
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