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
1 changed files with 7 additions and 3 deletions

View File

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