java.lang.IllegalStateException

Cannot call this method while RecyclerView is computing a layout or scrolling

Samebug tips1

This probably occurs because you are calling notifyItemInserted(position);, notifyItemChanged(position), or notifyItemRemoved(position); from a background thread (or from a callback, which runs on a background thread). Use a Handler to solve it.


rafaelrafael

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web36

  • Stack trace

    • java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2161) at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onChanged(RecyclerView.java:4249) at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyChanged(RecyclerView.java:9924) at android.support.v7.widget.RecyclerView$Adapter.notifyDataSetChanged(RecyclerView.java:5741) at com.virginredapp.ui.custom.ParallaxRecyclerAdapter.addData(ParallaxRecyclerAdapter.java:201) at com.virginredapp.ui.adapter.TreasureHuntFeedAdapter.addData(TreasureHuntFeedAdapter.java:94) at com.virginredapp.ui.fragments.TreasureHuntDashboardFragment.hideLoadmoreView(TreasureHuntDashboardFragment.java:257) at com.virginredapp.ui.fragments.TreasureHuntDashboardFragment.access$700(TreasureHuntDashboardFragment.java:86) at com.virginredapp.ui.fragments.TreasureHuntDashboardFragment$2.onScrolled(TreasureHuntDashboardFragment.java:283) at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:3948) at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3102) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2914) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3277) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) at android.widget.FrameLayout.onLayout(FrameLayout.java:388) at android.view.View.layout(View.java:15047) at android.view.ViewGroup.layout(ViewGroup.java:4676) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2189) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1896) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1103) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6018) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799) at android.view.Choreographer.doCallbacks(Choreographer.java:599) at android.view.Choreographer.doFrame(Choreographer.java:559) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:784) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5872) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674) at dalvik.system.NativeStart.main(Native Method)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    filpgamefilpgame
    2 times, last one
    Diogo JaymDiogo Jaym
    13 times, last one
    Hiren AmaliyarHiren Amaliyar
    2 times, last one
    Indri YunitaIndri Yunita
    Once,
    Aria PahlavanAria Pahlavan
    7 times, last one
    3 more bugmates