I have a recycler view ListAdapter (coming from androidx)
I know that one is not supposed to use notifyDataSetChanged() any more with a ListAdaper but I am in a situation where it's necessary (onBindViewHolder() should be invoked without changing the submitlist)
The problem is that I have a compilation error when I call notifyDataSetChanged() like this:
binding.episodesRv.adapter.notifyDataSetChanged()
Compilation error:
Smart cast to '({Adapter<(androidx.recyclerview.widget.RecyclerView.ViewHolder..
androidx.recyclerview.widget.RecyclerView.ViewHolder?)> & EpisodeListAdapter}..
EpisodeListAdapter)' is impossible, because 'bd.episodesRv.adapter' is a complex expression
The adapter :
class EpisodeListAdapter(
val context: Context,
var epiId: StateFlow<Long>,
val selectEpisode: (episode: Episode) -> Unit,
val delete: (episode: Episode) -> Unit,
) : ListAdapter<Episode, EpisodeViewHolder>(EPISODE_COMPARATOR) {
....
Issue fixed by Artem Chernousov in comments above. Thanks again.