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

嵌套使用,ItemViewDelegate对象出现多次重复加载,一直死循环。 #316

Open
graysonwu2018 opened this issue Mar 9, 2021 · 7 comments

Comments

@graysonwu2018
Copy link

SmartRefreshView + Multitype使用没有问题,数据可以正常加载。
ViewPager2 + Multitype使用没有问题,数据可以正常加载。
ViewPager2 + SmartRefreshView + Multitype使用就会出现重复加载的问题,严重时会出现死循环不停加载。

SmartRefreshView + Multitype 使用
image
image

ViewPager2 + SmartRefreshView + Multitype使用
image
image

@drakeet
Copy link
Owner

drakeet commented Mar 10, 2021 via email

@YunChe-Linghit
Copy link

感谢反馈,但看起来你使用的这个下拉刷新组件并非谷歌官方提供的,因此我们无法了解它做了什么错误的事情,你能否提供最小可复现程序工程,或者根据你的 debug 发起 PR?

________________________________ From: grayson [email protected] Sent: Tuesday, March 9, 2021 8:37:56 PM To: drakeet/MultiType [email protected] Cc: Subscribed [email protected] Subject: [drakeet/MultiType] 嵌套使用,ItemViewDelegate对象出现多次重复加载,一直死循环。 (#316) SmartRefreshView + Multitype使用没有问题,数据可以正常加载。 ViewPager2 + Multitype使用没有问题,数据可以正常加载。 ViewPager2 + SmartRefreshView + Multitype使用就会出现重复加载的问题,严重时会出现死循环不停加载。 SmartRefreshView + Multitype 使用 [image]https://user-images.githubusercontent.com/19201565/110471316-f5eac700-8116-11eb-81ca-6821d7e638e2.png [image]https://user-images.githubusercontent.com/19201565/110471404-0e5ae180-8117-11eb-808f-c6522ff60f22.png ViewPager2 + SmartRefreshView + Multitype使用 [image]https://user-images.githubusercontent.com/19201565/110471503-2af71980-8117-11eb-8563-5ae2978e0e54.png [image]https://user-images.githubusercontent.com/19201565/110471541-35b1ae80-8117-11eb-9d5e-944279d7a358.png ― You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub<#316>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABHZABTDX3N6BMGQBG2HSKLTCYJCJANCNFSM4Y3QKHHA.

最小可复现程序工程已上传到Github。
链接地址:https://github.com/YunChe-Linghit/MultitypeFix
麻烦看看到底出什么问题了。

@YunChe-Linghit
Copy link

排查出问题了吗?是因为什么问题导致的呢?

@drakeet
Copy link
Owner

drakeet commented Mar 18, 2021

@YunChe-Linghit 这个 issue 优先级不是很高,它大概率是你使用的另外的库的问题,因为 MultiType 理论上来说是很纯粹的,所以目前不会很紧急地进行处理,请再等等或尝试自行寻找原因和发起 PR。

@graysonwu2018
Copy link
Author

graysonwu2018 commented Apr 7, 2021 via email

@qdsfdhvh
Copy link

qdsfdhvh commented Apr 7, 2021

刚刚我没测试完全,除了标识,高度也必须和之前一样;两次嵌套的情况下第一次拿到的事最外层的高度,导致我刚刚的方法不可用,我就删掉了,我改成了下面这样应该可以解决,但是需要再优化:

private var saveHeight = 0

override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
    if (saveHeight > 0) {
        super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(
            saveHeight,
            MeasureSpec.EXACTLY
        ))
        return
    }

    val heightMode = MeasureSpec.getMode(heightMeasureSpec)
    if (heightMode == MeasureSpec.EXACTLY) {
        saveHeight = MeasureSpec.getSize(heightMeasureSpec)
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec)
}

@graysonwu2018
Copy link
Author

onMeasure

确实是不停的onMeasure导致的,我最近又发现了,版本是4.2.0版本,只是在ConstraintLayout布局中添加,并且有用到ViewPager2。

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

4 participants