Android - 在 recyclerview ListAdapter 中调用 notifyDataSetChanged()

Android - Call notifyDataSetChanged() on recycler view ListAdapter

我有一个回收器视图 ListAdapter(来自 androidx)

我知道不应该再对 ListAdaper 使用 notifyDataSetChanged() 但我处于一种有必要的情况(应该在不更改提交列表的情况下调用 onBindViewHolder())

问题是当我像这样调用 notifyDataSetChanged() 时出现编译错误:

binding.episodesRv.adapter.notifyDataSetChanged()

编译错误:

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

适配器:

class EpisodeListAdapter(
    val context: Context,
    var epiId: StateFlow<Long>,
    val selectEpisode: (episode: Episode) -> Unit,
    val delete: (episode: Episode) -> Unit,
) : ListAdapter<Episode, EpisodeViewHolder>(EPISODE_COMPARATOR) {
 ....

Artem Chernousov 在上面的评论中修复了问题。再次感谢。