mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 12:00:39 +01:00
fetch only favorited private contacts when requested so
This commit is contained in:
parent
4e3194aac8
commit
3abc0a8e66
@ -57,7 +57,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.29.9'
|
||||
implementation 'com.simplemobiletools:commons:5.29.10'
|
||||
implementation 'joda-time:joda-time:2.10.1'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
|
||||
|
@ -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?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user