BaseRecyclerViewAdapterHelper
BaseRecyclerViewAdapterHelper copied to clipboard
BaseNodeAdapter.kt中有一个bug会导致数组越界
` private fun removeNodesAt(position: Int): Int { if (position >= data.size) { return 0 } // 记录被移除的item数量 var removeCount = 0
// 先移除子项
removeCount = removeChildAt(position)
// 移除node自己
this.data.removeAt(position) !!!!!!!!!!!!!!注意这里, 已经移除了position处的item
removeCount += 1
val node = this.data[position] !!!!!!!!!!!!!!此时再去获取这个位置上的item,如果item总数为1, 那么这里就越界了
// 移除脚部
if (node is NodeFooterImp && node.footerNode != null) {
this.data.removeAt(position)
removeCount += 1
}
return removeCount
}
`
是的 也发现这个问题 最后一个父节点的最后一个子节点的移除会溢出 在没有footer的情况下
同出现了这个问题
复现就是创造一个只有一个父节点和一个子节点的就能复现了
每个父节点都展开, 然后点击父节点也会出现数组越界
+1,继承LinearLayoutManager,onLayoutChildren中trycatch一下,勉强不蹦
同样的问题,大家都怎么解决的
同求解决方案
我也遇到了这个问题