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

当启用悬停时,RecycleView addOnScrollListener 有问题 #108

Closed
the6nnoo opened this issue Feb 25, 2022 · 6 comments
Closed

当启用悬停时,RecycleView addOnScrollListener 有问题 #108

the6nnoo opened this issue Feb 25, 2022 · 6 comments
Labels
Bug Something isn't working

Comments

@the6nnoo
Copy link
Contributor

the6nnoo commented Feb 25, 2022

binding.rv.addOnScrollListener(object : RecyclerView.OnScrollListener() {
    override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
        super.onScrollStateChanged(recyclerView, newState)
        val layoutManager = recyclerView.layoutManager as LinearLayoutManager
        var lastItemPosition = layoutManager.findLastVisibleItemPosition()
        Log.d("Tag Tag", lastItemPosition.toString())

    }
})

这里滑动时,打印的值一直是个0

@the6nnoo the6nnoo added the 寻求帮助 Extra attention is needed label Feb 25, 2022
@liangjingkanji liangjingkanji added Bug Something isn't working and removed 寻求帮助 Extra attention is needed labels Feb 25, 2022
@liangjingkanji
Copy link
Owner

liangjingkanji commented Feb 27, 2022

你下载demo查看问题是否已经修复, 没问题我就发布新版本

@the6nnoo
Copy link
Contributor Author

the6nnoo commented Feb 27, 2022

我看了你的实现方法,这样做的方式是不是会要将LinearLayoutManager里面所有的方法都这样重写才行。
例如:findViewByPosition()

@liangjingkanji
Copy link
Owner

findViewByPosition有问题吗?

@the6nnoo
Copy link
Contributor Author

detachHover();
attachHover();
这两个方法在实际使用中会超高的频率调用,这样在稍微复杂的页面里会显得很卡

@liangjingkanji
Copy link
Owner

liangjingkanji commented Mar 14, 2022

为了快速定位问题,你最好fork仓库复现问题发我地址. 因为不见得是这两个函数导致卡顿

@liangjingkanji
Copy link
Owner

如果你是指的OnHoverAttachListenerdetachHover /attachHover调用频率高, 那么我建议你在里面自己判断或者少做复杂计算

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants