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,10 +166,13 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
|
||||||
// Add listener to changes in the SearchView's text to update the suggestions
|
// Add listener to changes in the SearchView's text to update the suggestions
|
||||||
mSearchView?.queryTextChangeEvents()
|
mSearchView?.queryTextChangeEvents()
|
||||||
?.skipInitialValue()
|
?.skipInitialValue()
|
||||||
?.debounce(500, TimeUnit.MILLISECONDS)
|
?.debounce(200, TimeUnit.MILLISECONDS)
|
||||||
?.map { it.queryText.toString().toLowerCase() }
|
?.map { it.queryText.toString().toLowerCase() }
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.subscribe {
|
?.subscribe {
|
||||||
|
if (it.length < 2)
|
||||||
|
mSearchView?.suggestionsAdapter?.changeCursor(null)
|
||||||
|
else
|
||||||
updateSearchViewSuggestions(it)
|
updateSearchViewSuggestions(it)
|
||||||
}?.let {
|
}?.let {
|
||||||
mDisposables.add(it)
|
mDisposables.add(it)
|
||||||
|
|
Loading…
Reference in a new issue