From 22a4cca1fe3fc8704fb35ce13dec1210888202e5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 30 Apr 2018 23:41:46 +0200 Subject: [PATCH] add a helper function for getting contact sources synchronously --- .../contacts/helpers/ContactsHelper.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt index 079cc8ae..6b52f1bf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -637,12 +637,16 @@ class ContactsHelper(val activity: BaseSimpleActivity) { fun getContactSources(callback: (ArrayList) -> Unit) { Thread { - val sources = getDeviceContactSources() - sources.add(ContactSource(activity.getString(R.string.phone_storage_hidden), SMT_PRIVATE)) - callback(ArrayList(sources)) + callback(getContactSourcesSync()) }.start() } + private fun getContactSourcesSync(): ArrayList { + val sources = getDeviceContactSources() + sources.add(ContactSource(activity.getString(R.string.phone_storage_hidden), SMT_PRIVATE)) + return ArrayList(sources) + } + private fun getDeviceContactSources(): LinkedHashSet { val sources = LinkedHashSet() if (!activity.hasContactPermissions()) {