cymcsg / UltimateRecyclerView

A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.
Apache License 2.0
7.22k stars 1.43k forks source link

java.lang.IndexOutOfBoundsException #466

Open lowfiend opened 7 years ago

lowfiend commented 7 years ago

Hello

I got this error and found a page to explain this error. But I don't know how to fix this error. plz help me

`java.lang.IndexOutOfBoundsException
Inconsistency detected. Invalid item position 35(offset:35).state:36

android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4041)
android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3999)
android.support.v7.widget.LayoutState.next(LayoutState.java:83)
android.support.v7.widget.StaggeredGridLayoutManager.fill(StaggeredGridLayoutManager.java:1412)
android.support.v7.widget.StaggeredGridLayoutManager.scrollBy(StaggeredGridLayoutManager.java:1878)
android.support.v7.widget.StaggeredGridLayoutManager.scrollVerticallyBy(StaggeredGridLayoutManager.java:1796)
android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1204)
android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:1951)
android.view.View.dispatchTouchEvent(View.java:8497)`

http://blog.csdn.net/msn465780/article/details/53907772

lowfiend commented 7 years ago

I found the bug in this issue. I use StaggeredGridLayoutManager & setCustomLoadMoreView. I disableLoadMore use three funtion :

  1. ultimateRecyclerView.disableLoadmore()
  2. ultimateViewAdapter.enableLoadMore(false)
  3. ultimateViewAdapter.internalExecuteLoadingView()

It would cause java.lang.IndexOutOfBoundsException error.

step: Very slow scorlling, it will happen.

If you setLayoutManager is LinearLayoutManager, it works good not crash. plz fix this bug, thank u.

lowfiend commented 7 years ago

@cymcsg