mancj / mancj/MaterialSearchBar
After filtering suggestions, list size doesn't change
- Dominant language
- Java
- Stars
- 2k
- Forks
- 324
- PR merge metrics
- No merged PRs in 30d
Description

Using a filter as the user enters in text (as shown in the library example) which works as expected - but am unable to animate suggestions without listening to the filter and calling `searchBar.updateSuggestions(...)`. Would expect this to happen natively.
As of now, doing away with the adapter filter and manually updating suggestions within the text changed listener.
```
override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
if (!search_bar.isSearchEnabled) return
if (charSequence.isNotEmpty()) {
search_bar.updateLastSuggestions(search_bar.lastSuggestions.filter {
val artist = it as Artist
artist.name?.contains(charSequence.toString(), true) ?: false
})
} else {
search_bar.updateLastSuggestions(mainViewModel.lastSearchedArtists.value?.getData())
}
}
```
Which I guess isn't a terrible approach, just feels like an antipattern with adapter filter logic.
Feel free to close if this is indeed the suggested use case, if so, maybe update the example? https://github.com/mancj/MaterialSearchBar/blob/master/app/src/main/java/com/mancj/example/custom/CustomAdapterActivity.java
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with app/src/main/java/com/mancj/example/custom/CustomAdapterActivity.java and review the adapter filter behavior alongside searchBar.updateSuggestions(...) and updateLastSuggestions(...). Reproduce the filtering flow from the issue and determine whether the suggestions list size and animation should update natively; done means the behavior is corrected or the example documents the intended approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- frontend, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100