You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following is the recycler view defined with the animation:
mRecyclerView = rootView.findViewById(R.id.list1);
mRecyclerView.setLayoutManager(new GridLayoutManager(fragmentActivity, 2));
mRecyclerView.setHasFixedSize(true);
mAdapter = new MediaGridAdapter(fragmentActivity, mediaModels);
MyScaleInAnimator animator = new MyScaleInAnimator(mAdapter);
animator.setAddDuration(100);
animator.setRemoveDuration(100);
mRecyclerView.setItemAnimator(animator);
The following is how I remove items from the recycler view:
public void removeData(String fileType, int position, Context context) {
mediaModels.remove(position);
notifyItemRemoved(position);
}
(When I am deleting multiple items, this method is called multiple times iterativey). Problem:
When I select a small numbers of items from the recycler view, the above delete method functions as expected. But If I select a large number of items(50-100) & delete immediately, the following exception is thrown:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.akl.alldrive, PID: 26558 java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{f308d5b position=54 id=-1, oldPos=74, pLpos:54 scrap [attachedScrap] tmpDetached no parent} android.support.v7.widget.RecyclerView{7b12cb3 VFED.V... ......I. 0,147-1080,1857 #7f0a0099 app:id/list1}, adapter:jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter@780c270, layout:android.support.v7.widget.GridLayoutManager@fb119e9, context:com.akl.alldrive.activities.BaseActivity@2c3cc96 at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5715) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5898) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230) at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:557) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612) at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:171) at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3875) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3639) at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1888) at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:407) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966) at android.view.Choreographer.doCallbacks(Choreographer.java:778) at android.view.Choreographer.doFrame(Choreographer.java:710) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6798) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4 Process: com.akl.alldrive, PID: 26558 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling android.support.v7.widget.RecyclerView{7b12cb3 VFED.V... ......I. 0,147-1080,1857 #7f0a0099 app:id/list1}, adapter:jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter@780c270, layout:android.support.v7.widget.GridLayoutManager@fb119e9, context:com.akl.alldrive.activities.BaseActivity@2c3cc96 at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2880) at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeRemoved(RecyclerView.java:5308) at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeRemoved(RecyclerView.java:12032) at android.support.v7.widget.RecyclerView$Adapter.notifyItemRemoved(RecyclerView.java:7231) at com.akl.alldrive.adapters.MediaGridAdapter.removeData(MediaGridAdapter.java:60)
How to get around this issue?
The text was updated successfully, but these errors were encountered:
The following is the recycler view defined with the animation:
The following is how I remove items from the recycler view:
(When I am deleting multiple items, this method is called multiple times iterativey).
Problem:
When I select a small numbers of items from the recycler view, the above delete method functions as expected. But If I select a large number of items(50-100) & delete immediately, the following exception is thrown:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.akl.alldrive, PID: 26558 java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{f308d5b position=54 id=-1, oldPos=74, pLpos:54 scrap [attachedScrap] tmpDetached no parent} android.support.v7.widget.RecyclerView{7b12cb3 VFED.V... ......I. 0,147-1080,1857 #7f0a0099 app:id/list1}, adapter:jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter@780c270, layout:android.support.v7.widget.GridLayoutManager@fb119e9, context:com.akl.alldrive.activities.BaseActivity@2c3cc96 at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5715) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5898) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230) at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:557) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612) at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:171) at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3875) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3639) at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1888) at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:407) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966) at android.view.Choreographer.doCallbacks(Choreographer.java:778) at android.view.Choreographer.doFrame(Choreographer.java:710) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6798) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4 Process: com.akl.alldrive, PID: 26558 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling android.support.v7.widget.RecyclerView{7b12cb3 VFED.V... ......I. 0,147-1080,1857 #7f0a0099 app:id/list1}, adapter:jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter@780c270, layout:android.support.v7.widget.GridLayoutManager@fb119e9, context:com.akl.alldrive.activities.BaseActivity@2c3cc96 at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2880) at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeRemoved(RecyclerView.java:5308) at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeRemoved(RecyclerView.java:12032) at android.support.v7.widget.RecyclerView$Adapter.notifyItemRemoved(RecyclerView.java:7231) at com.akl.alldrive.adapters.MediaGridAdapter.removeData(MediaGridAdapter.java:60)
How to get around this issue?
The text was updated successfully, but these errors were encountered: