mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
implementing Search at the favorites tab
This commit is contained in:
@@ -153,7 +153,7 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
override fun onQueryTextChange(newText: String): Boolean {
|
||||
if (isSearchOpen) {
|
||||
contacts_fragment?.onSearchQueryChanged(newText)
|
||||
getCurrentFragment()?.onSearchQueryChanged(newText)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -168,7 +168,7 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
|
||||
contacts_fragment?.onSearchClosed()
|
||||
getCurrentFragment()?.onSearchClosed()
|
||||
isSearchOpen = false
|
||||
main_dialpad_button.beVisible()
|
||||
return true
|
||||
@@ -306,6 +306,12 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, recents_fragment).toMutableList() as ArrayList<MyViewPagerFragment?>
|
||||
|
||||
private fun getCurrentFragment(): MyViewPagerFragment? = when (viewpager.currentItem) {
|
||||
0 -> contacts_fragment
|
||||
1 -> favorites_fragment
|
||||
else -> recents_fragment
|
||||
}
|
||||
|
||||
private fun getDefaultTab(): Int {
|
||||
return when (config.defaultTab) {
|
||||
TAB_LAST_USED -> config.lastUsedViewPagerPage
|
||||
|
@@ -113,10 +113,16 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||
}
|
||||
|
||||
override fun onSearchClosed() {
|
||||
|
||||
(fragment_list.adapter as? ContactsAdapter)?.updateItems(allContacts)
|
||||
setupLetterFastscroller(allContacts)
|
||||
}
|
||||
|
||||
override fun onSearchQueryChanged(text: String) {
|
||||
val contacts = allContacts.filter {
|
||||
it.name.contains(text, true) || it.doesContainPhoneNumber(text)
|
||||
}.toMutableList() as ArrayList<SimpleContact>
|
||||
|
||||
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contacts, text)
|
||||
setupLetterFastscroller(contacts)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user