BaseRecyclerViewAdapterHelper
BaseRecyclerViewAdapterHelper copied to clipboard
V4.1.4 - GridLayoutManager在过渡为状态布局时会导致 ItemDecoration 失效
- 当前使用的版本号: 4.1.4
- 复现操作描述:
- RecyclerView使用
GridLayoutManager/QuickGridLayoutManager(StaggeredGridLayoutManager没有尝试,但预估会发生同样的问题), 添加ItemDecoration - 启用状态布局, 并设置状态布局
- 调用
submitList(emptyList())设置数据为空 - 此时会发生
ItemDecoration被清空的情况.
- RecyclerView使用
- 已经Fork项目, 并在已创建出现问题的代码, 请查看链接: https://github.com/Chen-Xi-g/BaseRecyclerViewAdapterHelper
- 复现视频
https://github.com/user-attachments/assets/ae877b22-2090-4048-bb0e-d4ad1a1687b7
问题发生在调用submitList之后调用了notifyItemRangeRemoved,
open fun submitList(list: List<T>?) {
// ......
if (newDisplayEmptyLayout && !oldDisplayEmptyLayout) {
notifyItemRangeRemoved(0, items.size)
items = newList
notifyItemInserted(0)
} // ......
}