donglua / PhotoPicker

[DEPRECATED] Image Picker like Wechat
https://play.google.com/store/apps/details?id=me.iwf.PhotoPickerDemo
Apache License 2.0
2.83k stars 683 forks source link

数组越界 #253

Open realicing opened 6 years ago

realicing commented 6 years ago

main(1)

java.lang.IndexOutOfBoundsException Index: 2, Size: 1

1 java.util.ArrayList.get(ArrayList.java:411) 2 me.iwf.photopicker.a.d.d(SelectableAdapter.java:77) 3 me.iwf.photopicker.a.a.getItemCount(PhotoGridAdapter.java:162) 4 android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3722) 5 android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3527) 6 android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4082) 7 android.view.View.layout(View.java:17697) 8 android.view.ViewGroup.layout(ViewGroup.java:5736) 9 android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) 10 android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)

hyvenzhu commented 6 years ago

我也遇到,日志收集到的,希望楼主能看下!

xingstarx commented 5 years ago

修改SelectableAdapter.java里面的getCurrentPhotos方法

public List<Photo> getCurrentPhotos() {
    if (photoDirectories.size() <= currentDirectoryIndex) {
      currentDirectoryIndex = photoDirectories.size() - 1;
    }
    return photoDirectories.get(currentDirectoryIndex).getPhotos();
  }

即可解决问题

xingstarx commented 5 years ago

之前写的判断条件写错了,应该是小于等于