BaseRecyclerViewAdapterHelper icon indicating copy to clipboard operation
BaseRecyclerViewAdapterHelper copied to clipboard

V4.1.4 - GridLayoutManager在过渡为状态布局时会导致 ItemDecoration 失效

Open Chen-Xi-g opened this issue 1 year ago • 0 comments

  1. 当前使用的版本号: 4.1.4
  2. 复现操作描述:
    1. RecyclerView使用GridLayoutManager/QuickGridLayoutManager(StaggeredGridLayoutManager没有尝试,但预估会发生同样的问题), 添加ItemDecoration
    2. 启用状态布局, 并设置状态布局
    3. 调用submitList(emptyList())设置数据为空
    4. 此时会发生ItemDecoration被清空的情况.
  3. 已经Fork项目, 并在已创建出现问题的代码, 请查看链接: https://github.com/Chen-Xi-g/BaseRecyclerViewAdapterHelper
  4. 复现视频

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)
    } // ......
}

Chen-Xi-g avatar Nov 13 '24 09:11 Chen-Xi-g