4

I have implemented the Endless scroll with RecyclerView. When user hit the bottom I'm adding null object to display progress in AsyncTask onPreExecute and notify adapter item Inserted. This code I have been using for quiet some time already. Recently I have updated android Support Library From 23.0.3 to 24.2.1. Since then I am getting exception when hit bottom of the list.

Cannot call this method in a scroll callback. Scroll callbacks might be run during a measure & layout pass where you cannot change the RecyclerView data. Any method call that might change the structure of the RecyclerView or the adapter contents should be postponed to the next frame.
java.lang.IllegalStateException: 
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2403)
at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeInserted(RecyclerView.java:4634)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:10472)
at android.support.v7.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:6214)
at com.test.film.buzz.BuzzFeedsFragment$5.onPreExecute(BuzzFeedsFragment.java:229)
at com.test.utils.ParallelAsyncTask.executeOnExecutor(ParallelAsyncTask.java:595)
at com.test.utils.ParallelAsyncTask.execute(ParallelAsyncTask.java:543)
at com.test.film.buzz.BuzzFeedsFragment.onLoadMore(BuzzFeedsFragment.java:258)
at com.test.film.buzz.BuzzFeedsFragment$3.onScrolled(BuzzFeedsFragment.java:177)
at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4305)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4463)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:616)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)                                                   
Reaz Murshed
  • 21,071
  • 12
  • 69
  • 87

0 Answers0