mancj / mancj/MaterialSearchBar

After filtering suggestions, list size doesn't change

Open
#103 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2k
Forks
324
PR merge metrics
No merged PRs in 30d

Description

![image](https://user-images.githubusercontent.com/3791583/50596802-fcac8e00-0e6a-11e9-875f-7490617af098.png)

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.