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

预加载问题:默认首次不预加载(ScrollSpeedManger引发) #1246

Open
Fylan0 opened this issue Sep 29, 2024 · 0 comments
Open

Comments

@Fylan0
Copy link

Fylan0 commented Sep 29, 2024

预加载:默认首次不预加载,预加载数量也不是SDK中设置的 2(ScrollSpeedManger引发)

v:2.2.3

使用配置:

  • mIsInfiniteLoop = false;
  • mIsAutoLoop = false;

问题

首次创建后,ImageAdapter只会创建第一个。当触发滑动后才会创建第二个item(可通过日志测试)。
当第二章图片较大,如果滑动才触发加载会导致先展示不出来,不符合预加载。
image

内部使用的setOffscreenPageLimit未生效。
mViewPager2.setOffscreenPageLimit(2);

原因:

ScrollSpeedManger.reflectLayoutManager(this);
通过反射替换了ViewPager2中RecyclerView中的LinearLayoutManager。

ViewPager2中LinearLayoutManagerImpl默认会通过mOffscreenPageLimit处理预加载(计算屏幕外需要加载item)。

image

适配:
如果保留ScrollSpeedManger,需要适配ViewPager2中LinearLayoutManagerImpl中原有方法

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