Improve responsivenes of suggestions in MerchantsFragment's SearchView by reducing the debounce effect and clearing the query results if the query is shorter than 2 chars.
This commit is contained in:
parent
9ecac53f62
commit
978e8d6ee2
1 changed files with 5 additions and 2 deletions
|
@ -166,11 +166,14 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
|
|||
// Add listener to changes in the SearchView's text to update the suggestions
|
||||
mSearchView?.queryTextChangeEvents()
|
||||
?.skipInitialValue()
|
||||
?.debounce(500, TimeUnit.MILLISECONDS)
|
||||
?.debounce(200, TimeUnit.MILLISECONDS)
|
||||
?.map { it.queryText.toString().toLowerCase() }
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe {
|
||||
updateSearchViewSuggestions(it)
|
||||
if (it.length < 2)
|
||||
mSearchView?.suggestionsAdapter?.changeCursor(null)
|
||||
else
|
||||
updateSearchViewSuggestions(it)
|
||||
}?.let {
|
||||
mDisposables.add(it)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue