0

I am exploring the Algolia search suggestion, I am facing an issue that the search suggestion adapter is not getting refreshed when I start typing it keeps on showing the same suggestion, It should show the matching suggestion because I already connected the search view, Is there any extra thing I need to do I followed your documentation regarding Algolia search suggestion

Algolia Search Suggestion For Android

I think the query change listener is conflicting, check the code snippet below

Approach 1 Not Working

searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
        showSuggestions()
        showProducts()
    }

Approach 2 Not Working

searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
        override fun onQueryTextSubmit(query: String?): Boolean {
            return true
        }

        override fun onQueryTextChange(newText: String?): Boolean {
            showSuggestions()
            showProducts()
            return true
        }

    })
Fazal Hussain
  • 1,129
  • 12
  • 28

1 Answers1

0

Looks like you are calling both showSuggestions() and showProducts() methods same time, which could lead to the issue,

Can you try to modify the code as here and see?

searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
    if (hasFocus) showSuggestions() else showProducts()
}

Also, make sure to use the setReorderingAllowed(true) method inside the showSuggestions() and showProducts() methods.

Waseem
  • 439
  • 3
  • 18