I have a RecyclerView with a checkbox component, underneath there is a list of POJO with "isSelected" attribute.
Everything work fine when no items are selected at startup.
But in some conditions, I will need to show the list with the checkbox selected at start.
So I added some logic in the bind
method in the adapter.
And works fine.
But now I want to show the user the qty of lines selected!
in the fragment I'm trying to filter and count the elements in the list that area selected
ensayoSeleccionAdapter.submitList(it.data)
binding.btnSeleccionar.isEnabled = true
val selected = ensayoSeleccionAdapter.currentList.filter { e -> e.isSelected }
The problem is that I only get an empty list.
I try to use:
ensayoSeleccionAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
but the result is the same.
Any idea? Thanks!