Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecyclerView shows handle when Filterable returns an empty list #89

Open
jacopotediosi opened this issue Apr 18, 2023 · 0 comments
Open

Comments

@jacopotediosi
Copy link

Behavior similar to #5, the handle is shown when the adapter implements Filterable and the search filter returns an empty dataset.
As a bonus, this caused my app to crash when touching the handle in that situation, because my implementation of the getSectionText() method, calling .get() on an empty list, threw an ArrayIndexOutOfBoundsException.

I fixed implementing the following code in my class, but in my opinion this should be managed by the Fastscroller itself:

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        MyClassBinding binding = MyClassBinding.inflate(getLayoutInflater());
        FastScrollRecyclerView recyclerView = binding.recyclerView;
        
        [... myAdapter initialization ...]

        myAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
                @Override public void onChanged() {
                        super.onChanged();
                        recyclerView.setFastScrollEnabled(myAdapter.getItemCount() != 0);
                }
        });

        [...]

        return binding.getRoot();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant