When i scroll my recyclerview too fast i am getting the following crash
java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true
at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5659)
at android.support.v7.widget.RecyclerView$Recycler.recycleView(RecyclerView.java:5603)
at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:277)
at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:324)
at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:337)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:344)
at android.support.v7.widget.GapWorker.run(GapWorker.java:370)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I had tried my every effort and get similar question on stackoverflow, but none of them were helpful like following links,
Link 1
Link 2
Link 3
Link 4
Link 5
I have no knowledge of this crash from where it is occurring. Any help would be greatly appreciated. I am neither using "android:animateLayoutChanges="true"
Basically i had tried to merge these two different GitHub project,
rv-adapter-states
rv-adapter-endless
My files links are as follows from pastbin,
Row Layout
Code of recyclerview
My Adapter merge from two diffrent adapter of rv
Main adapter
I had the same problem and I don't know why is happening.
I solved it removing the android:animateLayoutChanges
on the recyclerview and to animate the recyclerview I have added:
recyclerView.setItemAnimator(new DefaultItemAnimator());
Take an account to add the method public long getItemId(int position)
and set setHasStableIds(true)
if you want animate it.
Have you tried layoutManager.setItemPrefetchEnabled(false);
? It worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With