do not apply the contact source filtering to Favorites

This commit is contained in:
tibbi 2017-12-30 16:52:05 +01:00
parent 488a5d9025
commit a67cb33cdc
3 changed files with 8 additions and 11 deletions

View File

@ -168,6 +168,7 @@ class MainActivity : SimpleActivity() {
private fun showSortingDialog() {
ChangeSortingDialog(this) {
contacts_fragment.initContacts()
favorites_fragment.initContacts()
}
}

View File

@ -85,9 +85,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
Contact.sorting = config.sorting
contacts.sort()
if (this is FavoritesFragment) {
contacts = if (this is FavoritesFragment) {
val favorites = config.favorites
contacts = contacts.filter { favorites.contains(it.id.toString()) } as ArrayList<Contact>
contacts.filter { favorites.contains(it.id.toString()) } as ArrayList<Contact>
} else {
val contactSources = config.displayContactSources
contacts.filter { contactSources.contains(it.source) } as ArrayList<Contact>
}
if (contacts.hashCode() != (fragment_list.adapter as? ContactsAdapter)?.contactItems?.hashCode()) {

View File

@ -24,7 +24,6 @@ import com.simplemobiletools.contacts.models.Contact
import com.simplemobiletools.contacts.models.Email
import com.simplemobiletools.contacts.models.Event
import com.simplemobiletools.contacts.models.PhoneNumber
import com.simplemobiletools.contacts.overloads.times
import java.io.ByteArrayOutputStream
import java.util.*
@ -32,16 +31,10 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
fun getContacts(callback: (ArrayList<Contact>) -> Unit) {
val contacts = SparseArray<Contact>()
Thread {
val sources = activity.config.displayContactSources
val questionMarks = ("?," * sources.size).trimEnd(',')
val uri = ContactsContract.Data.CONTENT_URI
val projection = getContactProjection()
var selection = "${ContactsContract.Data.MIMETYPE} = ?"
var selectionArgs = arrayOf(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
if (!activity.config.showAllContacts()) {
selection += " AND ${ContactsContract.RawContacts.ACCOUNT_NAME} IN ($questionMarks)"
selectionArgs += sources.toTypedArray()
}
val selection = "${ContactsContract.Data.MIMETYPE} = ?"
val selectionArgs = arrayOf(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
val sortOrder = getSortString()
var cursor: Cursor? = null