handle select sorting when search is active

This commit is contained in:
Pavel Poley 2022-05-15 12:24:49 +03:00
parent b2960c624e
commit b628a8f626
5 changed files with 18 additions and 5 deletions

View File

@ -45,6 +45,7 @@ class MainActivity : SimpleActivity() {
private var launchedDialer = false
private var searchMenuItem: MenuItem? = null
private var storedShowTabs = 0
private var searchQuery = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -176,6 +177,7 @@ class MainActivity : SimpleActivity() {
override fun onQueryTextChange(newText: String): Boolean {
if (isSearchOpen) {
searchQuery = newText
getCurrentFragment()?.onSearchQueryChanged(newText)
}
return true
@ -475,7 +477,16 @@ class MainActivity : SimpleActivity() {
private fun showSortingDialog() {
ChangeSortingDialog(this) {
refreshFragments()
favorites_fragment?.refreshItems {
if (isSearchOpen){
getCurrentFragment()?.onSearchQueryChanged(searchQuery)
}
}
contacts_fragment?.refreshItems {
if (isSearchOpen){
getCurrentFragment()?.onSearchQueryChanged(searchQuery)
}
}
}
}
}

View File

@ -72,7 +72,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
)
}
override fun refreshItems() {
override fun refreshItems(callback: (() -> Unit)?) {
val privateCursor = context?.getMyContactsCursor(false, true)
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
allContacts = contacts
@ -85,6 +85,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
activity?.runOnUiThread {
gotContacts(contacts)
callback?.invoke()
}
}
}

View File

@ -46,7 +46,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
letter_fastscroller_thumb.thumbColor = properPrimaryColor.getColorStateList()
}
override fun refreshItems() {
override fun refreshItems(callback: (() -> Unit)?) {
val privateCursor = context?.getMyContactsCursor(true, true)
SimpleContactsHelper(context).getAvailableContacts(true) { contacts ->
allContacts = contacts
@ -59,6 +59,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
activity?.runOnUiThread {
gotContacts(contacts)
callback?.invoke()
}
}
}

View File

@ -45,7 +45,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
}
}
override fun refreshItems() {
override fun refreshItems(callback: (() -> Unit)?) {
val privateCursor = context?.getMyContactsCursor(false, true)
val groupSubsequentCalls = context?.config?.groupSubsequentCalls ?: false
RecentsHelper(context).getRecentCalls(groupSubsequentCalls) { recents ->

View File

@ -1,5 +1,5 @@
package com.simplemobiletools.dialer.interfaces
interface RefreshItemsListener {
fun refreshItems()
fun refreshItems(callback: (() -> Unit)? = null)
}