Skip to content

Commit cc3a5ae

Browse files
authored
Fix the crash using DiffUtil with FlexboxLayoutManager. (#425)
Fixes #332
1 parent c8ba335 commit cc3a5ae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,8 @@ private void assignFromView(View anchor) {
28762876
mPosition = getPosition(anchor);
28772877
mAssignedFromSavedState = false;
28782878
assert mFlexboxHelper.mIndexToFlexLine != null;
2879-
int flexLinePosition = mFlexboxHelper.mIndexToFlexLine[mPosition];
2879+
int flexLinePosition =
2880+
mFlexboxHelper.mIndexToFlexLine[mPosition != NO_POSITION ? mPosition : 0];
28802881
mFlexLinePosition = flexLinePosition != NO_POSITION ? flexLinePosition : 0;
28812882
// It's likely that the view is the first item in a flex line, but if not get the
28822883
// index of the first item in the same line because the calculation of the flex lines

0 commit comments

Comments
 (0)