apply search to phone numbers too

This commit is contained in:
tibbi 2017-12-31 09:50:48 +01:00
parent 5b88de8025
commit 108e72fd10
2 changed files with 8 additions and 1 deletions

View file

@ -174,6 +174,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
}
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
getCurrentFragment().onSearchClosed()
isSearchOpen = false
return true
}

View file

@ -158,7 +158,9 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
fun onSearchQueryChanged(text: String) {
(fragment_list.adapter as ContactsAdapter).apply {
val filtered = contactsIgnoringSearch.filter { it.getFullName(startNameWithSurname).contains(text, true) } as ArrayList
val filtered = contactsIgnoringSearch.filter {
it.getFullName(startNameWithSurname).contains(text, true) || it.phoneNumbers.any { it.value.contains(text, true) }
} as ArrayList
updateItems(filtered)
}
}
@ -167,6 +169,10 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
contactsIgnoringSearch = (fragment_list.adapter as ContactsAdapter).contactItems as ArrayList
}
fun onSearchClosed() {
(fragment_list.adapter as ContactsAdapter).updateItems(contactsIgnoringSearch)
}
private fun updateViewStuff() {
context.updateTextColors(fragment_wrapper)
fragment_fastscroller.updateBubbleColors()