BaseRecyclerViewAdapterHelper icon indicating copy to clipboard operation
BaseRecyclerViewAdapterHelper copied to clipboard

BaseNodeAdapter.kt中有一个bug会导致数组越界

Open tommsoft opened this issue 3 years ago • 8 comments

` 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
}

` 屏幕截图 2021-01-22 084036

tommsoft avatar Jan 22 '21 00:01 tommsoft

是的 也发现这个问题 最后一个父节点的最后一个子节点的移除会溢出 在没有footer的情况下

zsgfrtttt avatar Jan 22 '21 07:01 zsgfrtttt

同出现了这个问题

yangkile avatar Jan 22 '21 13:01 yangkile

复现就是创造一个只有一个父节点和一个子节点的就能复现了

yangkile avatar Jan 22 '21 13:01 yangkile

每个父节点都展开, 然后点击父节点也会出现数组越界

szhdev avatar Feb 02 '21 06:02 szhdev

+1,继承LinearLayoutManager,onLayoutChildren中trycatch一下,勉强不蹦

XjxBoom avatar Apr 11 '21 07:04 XjxBoom

同样的问题,大家都怎么解决的

visla-yewang avatar May 18 '21 04:05 visla-yewang

同求解决方案

zhupengxiang avatar Oct 21 '21 11:10 zhupengxiang

我也遇到了这个问题

mtj956052456 avatar Mar 12 '22 06:03 mtj956052456