Crash on data-set update when DiffUtils is used
See original GitHub issue- I have searched existing issues and confirmed this is not a duplicate
Issues and steps to reproduce
I’m seeing this crash when trying to filter my list items using a search query:
FATAL EXCEPTION: main
java.lang.ArrayIndexOutOfBoundsException: length=45; index=-1
at com.google.android.flexbox.FlexboxLayoutManager$AnchorInfo.assignFromView(FlexboxLayoutManager.java:2863)
at com.google.android.flexbox.FlexboxLayoutManager$AnchorInfo.access$1900(FlexboxLayoutManager.java:2792)
at com.google.android.flexbox.FlexboxLayoutManager.updateAnchorFromChildren(FlexboxLayoutManager.java:1136)
at com.google.android.flexbox.FlexboxLayoutManager.updateAnchorInfoForLayout(FlexboxLayoutManager.java:1032)
at com.google.android.flexbox.FlexboxLayoutManager.onLayoutChildren(FlexboxLayoutManager.java:700)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3844)
Steps to reproduce This started to happen after I added DiffUtils for showing item animations. Here’s what I’m doing:
List<FolderSubscription> oldSubscriptions = ...;
List<FolderSubscription> newSubscriptions = ...;
FolderSubscriptionDiffCallbacks callback = new FolderSubscriptionDiffCallbacks(oldSubscriptions, newSubscriptions);
DiffUtil.DiffResult folderDiffResult = DiffUtil.calculateDiff(callback, true /* detectMoves */);
folderAdapter.updateData(newSubscriptions);
folderDiffResult.dispatchUpdatesTo(folderAdapter);
Version of the flexbox library
I tested on both v0.3-alpha3 and v0.3.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Smart way to update RecyclerView using DiffUtil - Medium
This class is used to notify updates to a RecyclerView Adapter. It uses Eugene W. Myers's difference algorithm to calculate the minimal number...
Read more >How to properly use DiffUtils in Recycler view to update array ...
How to properly use DiffUtils in Recycler view to update array list? ... the same time when i use notifyDataSetChanged() app did not...
Read more >DiffUtil vs. notifyDataSetChanged() - Educative.io
DiffUtil is a utility class that can calculate the difference between two lists and output a list of update operations that converts the...
Read more >Efficient lists with DiffUtil and ListAdapter - Big Nerd Ranch
DiffUtil is a utility class that calculates the difference between two lists and outputs a list of update operations that converts the first ......
Read more >Get Threading Right with DiffUtil - Jon F Hancock
Use DiffUtil for rich animations in RecyclerView with a tiny amount of code. Now this is a story all about how. My dataset...
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 FreeTop 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
Top GitHub Comments
I’m having the same issue using Renderers library and their diff algorithm with FlexboxLayoutManager. The lib algorithm is the following:
Changing from their
adapter.diffUpdate(list)
to the conventional updating the list and callingadapter.notifyDataSetChanged();
works but I’ve lost the animation.@thagikura still getting this FC
Issues and steps to reproduce
Update the items in androidx.recyclerview.widget.RecyclerView with androidx.recyclerview.widget.ListAdapter
Expected behavior
The list should handle multiple changes
Version of the flexbox library
1.1.0
Link to code
happens when
adapter.submitList(newList)
gets called often. I have about 10 items in the list in my case, 1 item gets changed per call.