Git Product home page Git Product logo

Comments (9)

Jude95 avatar Jude95 commented on July 17, 2024

image

from rollviewpager.

wasneverlonely avatar wasneverlonely commented on July 17, 2024

没打全 ... int half = Integer.MAX_VALUE/2; 这一句太阻塞主线程了...

from rollviewpager.

Jude95 avatar Jude95 commented on July 17, 2024

现在还会ANR?
现在应该并不会有过多计算。

from rollviewpager.

wasneverlonely avatar wasneverlonely commented on July 17, 2024

只要用integer.max_value 适配页面数据的时候总会卡一段时间的

from rollviewpager.

Jude95 avatar Jude95 commented on July 17, 2024

如何复现?我测试都没问题。

from rollviewpager.

wasneverlonely avatar wasneverlonely commented on July 17, 2024

如果只是测试没有问题 但是加到项目里面就可以卡了

from rollviewpager.

Jude95 avatar Jude95 commented on July 17, 2024

所以问你如何复现。你在项目里能复现,demo里就不能复现?
我知道Integer.MAX_VALUE会在计算当前偏移位置时大量循环,但通过反射可以避免这个问题,这个方式也比其他方式优势明显。
多个项目使用这么久并没问题。都是开发者应该知道复现是解BUG第一步。

from rollviewpager.

summer-zhoujie avatar summer-zhoujie commented on July 17, 2024

@Jude95 Integer.MAX_VALUE会在计算当前偏移位置时大量循环,但通过反射可以避免这个问题,你好这个问题能解释下吗

from rollviewpager.

Jude95 avatar Jude95 commented on July 17, 2024

@jimUpdate 我将当前页设为Integer.MAX_VALUE/2,所以前后都有你一辈子都滑不完的页数,加上自己做的页面缓存就完美了。唯一的问题就是如何把页码设置到Integer.MAX_VALUE/2。
ViewPager里setCurrentItem时会调用setCurrentItemInternal,然后在‘populate’会进行计算,计算从当前位置到目标位置的偏移量,会获取每一页的信息,而一共有Integer.MAX_VALUE/2页。所以就ANR.
解决方式:我没有使用setCurrentItem而是通过反射设置当前页,就不会引起大量计算。而且只会在更新以及重设adapter时反射修改,也没什么性能问题。这个库好久没看,细节有些记不起了。

from rollviewpager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.