Skip to content

Instantly share code, notes, and snippets.

@Kpeved
Created November 2, 2019 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kpeved/1670abc0b91f8b421ecf79aa8fd0ad05 to your computer and use it in GitHub Desktop.
Save Kpeved/1670abc0b91f8b421ecf79aa8fd0ad05 to your computer and use it in GitHub Desktop.
fun getAllContacts(): Single<Map<Long, ContactModel>> {
return Single.fromCallable { loadAllContacts() } // here we load all contacts
.map { addPhoneNumbers(it) } // here we add phone numbers
.map { it.filter { !it.value.phoneNumbers.isNullOrEmpty() } } // here we filter empty contacts
.map { it.values.toList().groupBy { it.contactId }.mapValues { mergePhoneNumbers(it.value) } } //here additional merging happens
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment