add a helper function for getting contact sources synchronously

This commit is contained in:
tibbi
2018-04-30 23:41:46 +02:00
parent 24248699bc
commit 22a4cca1fe

View File

@ -637,12 +637,16 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
fun getContactSources(callback: (ArrayList<ContactSource>) -> Unit) { fun getContactSources(callback: (ArrayList<ContactSource>) -> Unit) {
Thread { Thread {
val sources = getDeviceContactSources() callback(getContactSourcesSync())
sources.add(ContactSource(activity.getString(R.string.phone_storage_hidden), SMT_PRIVATE))
callback(ArrayList(sources))
}.start() }.start()
} }
private fun getContactSourcesSync(): ArrayList<ContactSource> {
val sources = getDeviceContactSources()
sources.add(ContactSource(activity.getString(R.string.phone_storage_hidden), SMT_PRIVATE))
return ArrayList(sources)
}
private fun getDeviceContactSources(): LinkedHashSet<ContactSource> { private fun getDeviceContactSources(): LinkedHashSet<ContactSource> {
val sources = LinkedHashSet<ContactSource>() val sources = LinkedHashSet<ContactSource>()
if (!activity.hasContactPermissions()) { if (!activity.hasContactPermissions()) {