TradeMe/Covert

Cannot add item decoration during a scroll or layout

stephanepechard opened this issue · 2 comments

Hi,

I cannot manage to integrate Covert to my RecyclerView. When it tries to show it, I get the following error:

java.lang.IllegalStateException: Cannot add item decoration during a scroll or layout
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2771)
at android.support.v7.widget.RecyclerView$LayoutManager.assertNotInLayoutOrScroll(RecyclerView.java:7523)
at android.support.v7.widget.LinearLayoutManager.assertNotInLayoutOrScroll(LinearLayoutManager.java:1352)
at android.support.v7.widget.RecyclerView.addItemDecoration(RecyclerView.java:1486)
at android.support.v7.widget.RecyclerView.addItemDecoration(RecyclerView.java:1514)
at android.support.v7.widget.helper.ItemTouchHelper.setupCallbacks(ItemTouchHelper.java:473)
at android.support.v7.widget.helper.ItemTouchHelper.attachToRecyclerView(ItemTouchHelper.java:466)
at nz.co.trademe.covert.Covert.(Covert.kt:122)
at nz.co.trademe.covert.Covert.(Covert.kt:88)
at nz.co.trademe.covert.Covert$Builder.attachTo(Covert.kt:581)

I tried to remove the ItemDecoration I add myself to the RecyclerView, but with no luck. Do you have an idea how I could circumvent this?

Thanks

Hey @stephanepechard,

Are you able to share a sample project where I can reproduce this? I have a feeling Covert may be being initialised at a time where the RecyclerView is laying out, as the crash appears to be coming from ItemTouchHelper

Hi,
It's difficult for me at this time to provide a sample project, I got the bug when I try to integrate it in my big (and dated) project... I will try to look around the way Covert is initialised.
Thanks