mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
add a helper function for getting contact sources synchronously
This commit is contained in:
@ -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()) {
|
||||||
|
Reference in New Issue
Block a user