CymChad / BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter
http://www.recyclerview.org/
MIT License
24.2k stars 5.14k forks source link

4.0 BaseMultiItemAdapter和LeadingLoadStateAdapter一起使用 onItemViewType 中list[position] 角标越界 #3779

Closed ASguy closed 1 year ago

ASguy commented 1 year ago

binding.rvChat.layoutManager = LinearLayoutManager(this) helper = QuickAdapterHelper.Builder(mAdapter) // 使用默认样式的首部"加载更多" .setLeadingLoadStateAdapter(object : LeadingLoadStateAdapter.OnLeadingListener { override fun onLoad() { // 执行加载更多的操作,通常都是网络请求 requestUoFetch() }

            override fun isAllowLoading(): Boolean {
                // 是否允许触发“加载更多”
                return true
            }
        }).build()
    /**
     * 第三步,给 RecyclerView 设置 Adapter,
     * 注意:这个adapter不是前面创建的 mAdapter,而是 helper 所提供的 adapter(ConcatAdapter)
     */
    binding.rvChat.adapter = helper.adapter

binding.rvChat.postDelayed({ mAdapter.addAll(0, chatDataBeanList) if (count > 5) { /*

.onItemViewType { position, list -> // 根据数据,返回对应的 ItemViewType if (list[position].role == "user") { 1 } else { 2 } } 首次进入没有问题,向上加载的时候list.size = position了

limuyang2 commented 1 year ago

版本号是多少?

limuyang2 commented 1 year ago

我这里测试没有复现,检查下你是否中途修改了list

limuyang2 commented 1 year ago

长时间未回复,问题先关闭了

50kg commented 2 months ago

越界问题是不能重复clear list,必须每次new 新的list再submitList()进去

50kg commented 2 months ago

@limuyang2 如果第二次submitList 使用上一个相同的list,clear在addAll数据,必崩