jeasonlzy / ImagePicker

完全仿微信的图片选择,并且提供了多种图片加载接口,选择图片后可以旋转,可以裁剪成矩形或圆形,可以配置各种其他的参数

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

选择图片页面时,当屏幕熄灭后,再次打开 出现崩溃

KevinWard0910 opened this issue · comments

崩溃原因:java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
最终走到了 ImageDataSource——>onLoadFinished()方法 ——> 130行 allImagesFolder.cover = allImages.get(0);
操作方式:在图片选择页面,熄灭屏幕,然后打开屏幕,随后崩溃
测试手机:红米3 android 6.0
猜想:应该和图片选择页面的生命周期有关。 希望大神有时间看看

dvzhou commented 29 days ago
if ((activity.getLifecycle().getCurrentState() == STARTED || activity.getLifecycle().getCurrentState() == RESUMED) && imageFolders.size() > 0) {
return;
}

这样以后应该就没问题了

flyjiang2014 commented 24 days ago
if ((activity.getLifecycle().getCurrentState() == STARTED || activity.getLifecycle().getCurrentState() == RESUMED) && imageFolders.size() > 0) {
return;
}
这句代码加在哪里,加在 imageFolders.clear(); 前面吗?

dvzhou commented 24 days ago
是的