CymChad / BaseRecyclerViewAdapterHelper

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

多类型布局 第一次加载正常 ,下拉刷新重新设置数据 ,报错 ArrayIndexOutOfBoundsException #3752

Closed fwcjszyss closed 1 year ago

fwcjszyss commented 1 year ago
override fun getDataSuccess(mutableList: MutableList<VideoItemBean>) {
    list.clear()
    for (item in mutableList){
        var videoTitleBean = VideoTitleBean(item.dict_code,item.dict_name)
        list.add(videoTitleBean)

        for (videoItem in item.data!!){
            list.add(videoItem)
        }
    }
    adapter.notifyDataSetChanged()
    binding.refreshLayout.finishRefresh(true)
}

首次加载正常, 执行下拉刷新后报错 如下: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=33; index=-1 at java.util.ArrayList.get(ArrayList.java:439) at com.lipont.appk.ui.adapter.FunVideoAdapter$3.onItemViewType(FunVideoAdapter.kt:79)

onItemViewType(object : BaseMultiItemAdapter.OnItemViewTypeListener{ override fun onItemViewType(position: Int, list: List): Int {

            NLog.d("position = $position")  // 这里报错, position = -1 
            return list.get(position).itemType
        }

    }
limuyang2 commented 1 year ago

请说明下你使用的版本

limuyang2 commented 1 year ago

更新 beta12