mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
fetch only favorited private contacts when requested so
This commit is contained in:
@ -24,7 +24,7 @@ class MyContactsContentProvider : ContentProvider() {
|
||||
MyContactsContentProvider.COL_PHONE_NUMBER)
|
||||
)
|
||||
|
||||
LocalContactsHelper(context!!).getPrivateSimpleContactsSync().forEach {
|
||||
LocalContactsHelper(context!!).getPrivateSimpleContactsSync(selection == MyContactsContentProvider.FAVORITES_ONLY).forEach {
|
||||
matrixCursor.newRow()
|
||||
.add(MyContactsContentProvider.COL_RAW_ID, it.rawId)
|
||||
.add(MyContactsContentProvider.COL_CONTACT_ID, it.contactId)
|
||||
|
@ -17,8 +17,8 @@ import com.simplemobiletools.contacts.pro.models.LocalContact
|
||||
import com.simplemobiletools.contacts.pro.models.Organization
|
||||
|
||||
class LocalContactsHelper(val context: Context) {
|
||||
fun getAllContacts(): ArrayList<Contact> {
|
||||
val contacts = context.contactsDB.getContacts()
|
||||
fun getAllContacts(favoritesOnly: Boolean = false): ArrayList<Contact> {
|
||||
val contacts = if (favoritesOnly) context.contactsDB.getFavoriteContacts() else context.contactsDB.getContacts()
|
||||
val storedGroups = ContactsHelper(context).getStoredGroupsSync()
|
||||
return contacts.map { convertLocalContactToContact(it, storedGroups) }.toMutableList() as ArrayList<Contact>
|
||||
}
|
||||
@ -161,5 +161,5 @@ class LocalContactsHelper(val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
fun getPrivateSimpleContactsSync() = getAllContacts().mapNotNull { convertContactToSimpleContact(it) }
|
||||
fun getPrivateSimpleContactsSync(favoritesOnly: Boolean) = getAllContacts(favoritesOnly).mapNotNull { convertContactToSimpleContact(it) }
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ interface ContactsDao {
|
||||
@Query("SELECT * FROM contacts")
|
||||
fun getContacts(): List<LocalContact>
|
||||
|
||||
@Query("SELECT * FROM contacts WHERE starred = 1")
|
||||
fun getFavoriteContacts(): List<LocalContact>
|
||||
|
||||
@Query("SELECT * FROM contacts WHERE id = :id")
|
||||
fun getContactWithId(id: Int): LocalContact?
|
||||
|
||||
|
Reference in New Issue
Block a user