Open quibbler01 opened 2 years ago
使用 ConcatAdapter 这里判断 itemViewType 有问题,走了convert造成ArrayIndexOutOfBoundsException,看大佬能否修改一下,谢谢
override fun onBindViewHolder(holder: VH, position: Int) {
//Add up fetch logic, almost like load more, but simpler.
mUpFetchModule?.autoUpFetch(position)
//Do not move position, need to change before LoadMoreView binding
mLoadMoreModule?.autoLoadMore(position)
when (holder.itemViewType) {
LOAD_MORE_VIEW -> {
mLoadMoreModule?.let {
it.loadMoreView.convert(holder, position, it.loadMoreStatus)
}
}
HEADER_VIEW, EMPTY_VIEW, FOOTER_VIEW -> return
else -> convert(holder, getItem(position - headerLayoutCount))
}
}
@xiaoxiaohua333 怎么解决的老哥
尝试了几次,没有添加Header和其它Adapter无异,当addHeaderView后出现异常,数组越界。
java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1 at java.util.ArrayList.get(ArrayList.java:439) at com.chad.library.adapter.base.BaseQuickAdapter.getItem(BaseQuickAdapter.java:604) at com.chad.library.adapter.base.BaseQuickAdapter.onBindViewHolder(BaseQuickAdapter.java:931) at com.chad.library.adapter.base.BaseQuickAdapter.onBindViewHolder(BaseQuickAdapter.java:68) at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7254) at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337) at androidx.recyclerview.widget.NestedAdapterWrapper.onBindViewHolder(NestedAdapterWrapper.java:157) at androidx.recyclerview.widget.ConcatAdapterController.onBindViewHolder(ConcatAdapterController.java:368) at androidx.recyclerview.widget.ConcatAdapter.onBindViewHolder(ConcatAdapter.java:188)
是和ConcatAdapter的兼容性问题