Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 GestureDetector 检测双击删除,使用 removeAt 返回的 position 不能及时刷新,使用 remove 可以正常删除 #3878

Open
James7a33 opened this issue Jul 19, 2024 · 0 comments

Comments

@James7a33
Copy link

James7a33 commented Jul 19, 2024

注意

我的是RecyclerView 是多层嵌套的

private val gestureDetector =
GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
return true
}

        override fun onDoubleTap(e: MotionEvent): Boolean {
            val child = recyclerView.findChildViewUnder(e.x, e.y)
            child?.let {
                val position = recyclerView.getChildAdapterPosition(it)
                if (position != RecyclerView.NO_POSITION) {
                    listener.onItemDoubleClick(it, position)
                }
            }
            return true
        }
    })
双击删除后,返回的 postion 并不是 最新的

使用 BaseQuickAdapter 自带的 removeAt(postion)传入 listener.onItemDoubleClick(it, position)返回的 postion 会出现数组下标越界

使用 BaseQuickAdapter 自带的 remove(item)传入 删除的是正常的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant