Skip to content

Instantly share code, notes, and snippets.

@vestrel00
Last active December 25, 2021 23:38
Show Gist options
  • Save vestrel00/9904e4685fad59dec510fa503a83b104 to your computer and use it in GitHub Desktop.
Save vestrel00/9904e4685fad59dec510fa503a83b104 to your computer and use it in GitHub Desktop.
An advance contacts query using https://github.com/vestrel00/contacts-android
val contacts = Contacts(context)
.query()
.where {
(Name.GivenName startsWith "leo") and
(Email.Address { endsWith("gmail.com") or endsWith("hotmail.com") }) and
(Address.Country equalToIgnoreCase "us") and
(Event { (Date lessThan Date().toWhereString()) and (Type equalTo EventEntity.Type.BIRTHDAY) }) and
(Contact.Options.Starred equalTo true) and
(Nickname.Name equalTo "DarEdEvil") and
(Organization.Company `in` listOf("facebook", "FB")) and
(Note.Note.isNotNullOrEmpty())
}
.accounts(
Account("john.doe@gmail.com", "com.google"),
Account("john.doe@myspace.com", "com.myspace"),
)
.include { setOf(
Contact.Id,
Contact.DisplayNamePrimary,
Phone.Number
) }
.orderBy(ContactsFields.DisplayNamePrimary.desc())
.offset(0)
.limit(5)
.find()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment