IndexOutOfBoundsException in EpoxyModelGroup binding
See original GitHub issueHi,
We use EpoxyModelGroup
in our app and since then it crash on IndexOutOfBoundsException
(see stack-trace below). Unfortunately I cannot publish our code but I will try to repro in a sample app. The crash happen when a model group get updated and when the nested models increase.
It crash on this line in EpoxyModelGroup.java
EpoxyModel<?> previousModel = previousGroup.models.get(modelIndex);`
Before they were 4 models in the group and after the update there were 11 models.
java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
at java.util.ArrayList.get(ArrayList.java:437)
at com.airbnb.epoxy.EpoxyModelGroup$3.onModel(EpoxyModelGroup.java:144)
at com.airbnb.epoxy.EpoxyModelGroup.iterateModels(EpoxyModelGroup.java:197)
at com.airbnb.epoxy.EpoxyModelGroup.bind(EpoxyModelGroup.java:139)
at com.airbnb.epoxy.EpoxyViewHolder.bind(EpoxyViewHolder.java:57)
at com.airbnb.epoxy.BaseEpoxyAdapter.onBindViewHolder(BaseEpoxyAdapter.java:97)
at com.airbnb.epoxy.EpoxyControllerAdapter.onBindViewHolder(EpoxyControllerAdapter.java:16)
at com.airbnb.epoxy.BaseEpoxyAdapter.onBindViewHolder(BaseEpoxyAdapter.java:15)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194)
Using Epoxy 3.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
How to fix IndexOutOfBoundsException in RecyclerView ...
My app uses "Jetpack Navigation, DataBinding, ViewModel". A Fragment has RecyclerView. If I touch one of the items, it is navigated to B ......
Read more >EpoxyModel.getSpanSizeInternal - airbnb/epoxy - Tabnine
Defaults to using the span size of the first model. Override this if you need to customize it return models.get(0).getSpanSizeInternal(totalSpanCount ...
Read more >How to use ViewBinding for EpoxyModelGroup? - Airbnb/Epoxy
Issue Title Created Date Comment Count Updated Date
Mermaid format export not possible from the UI 1 2022‑04‑10 2022‑10‑12
Un‑support Utf‑8 Chinese words. 5 2022‑07‑11...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hm not sure if the fix affects everything. Because I am able to reproduce a similiar error with 3.3.0 without using ModelGroups 😕
It happens when scrolling too fast
hi, I faced the same issue and had a workaround while using the placeholders (they are very important for smooth scrolling) stack overflow answer , see update 2 of that answer