leochuan / ViewPagerLayoutManager

ViewPager like LayoutManager which supports some awesome animations and infinite scroll.
Apache License 2.0
1.75k stars 333 forks source link

Exception when try remove first item #54

Open landarskiy opened 6 years ago

landarskiy commented 6 years ago

After remove first element and call notifyItemRangeRemoved(0,1) in adapter I have got a exception

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 0(offset:-1).state:5 android.support.v7.widget.RecyclerView{bcf2aea VFED..... ......I. 0,360-1080,1474 #7f090167 app:id/recyclerView}
        at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5817)
        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)
        at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)
        at com.leochuan.ViewPagerLayoutManager.onLayoutChildren(ViewPagerLayoutManager.java:379)
leochuan commented 6 years ago

Not fixed yet, do not use version 2.0.17

leochuan commented 6 years ago

I think it has been fixed, try 2.0.17

leveychen commented 6 years ago

改了这个之后,在只有两张图片的时候刷新 adapter 有小概率出现闪屏,图片无限闪动。还原之前版本的代码就不会有这个问题

好像都会闪。只出现在两张图片的时候 notify change 就会闪

leochuan commented 6 years ago

@leveychen notifyDataSetChange 还是 notifyItemChanged notifyItemRangeChanged 这些?

leveychen commented 6 years ago

@leochuan notifyDataSetChanged 场景是这样的,网络获取图片,然后 adapter.setDatas() adapter.notifyDataSetChanged() 在只有两张图片set进去的情况下,有一定概率出现图片闪动