Skip to content

Commit

Permalink
Fix regression spamming create views. Closes #50.
Browse files Browse the repository at this point in the history
  • Loading branch information
TonicArtos committed Mar 3, 2015
2 parents 0ae49f8 + a395bd4 commit 3088e19
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions library/src/main/java/com/tonicartos/superslim/GridSLM.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@ public int computeHeaderOffset(int firstVisiblePosition, SectionData sd, LayoutS
@Override
public int fillToEnd(int leadingEdge, int markerLine, int anchorPosition, SectionData sd,
LayoutState state) {
if (markerLine >= leadingEdge) {
return markerLine;
}

final int itemCount = state.recyclerState.getItemCount();
if (anchorPosition >= itemCount) {
return markerLine;
}

LayoutState.View anchor = state.getView(anchorPosition);
state.cacheView(anchorPosition, anchor.view);
if (anchor.getLayoutParams().getTestedFirstPosition() != sd.firstPosition) {
state.cacheView(anchorPosition, anchor.view);
return markerLine;
}

Expand Down Expand Up @@ -223,9 +227,9 @@ public int fillToStart(int leadingEdge, int markerLine, int anchorPosition, Sect
}

LayoutState.View rowAnchor = state.getView(i);
state.cacheView(i, rowAnchor.view);
LayoutManager.LayoutParams params = rowAnchor.getLayoutParams();
if (params.isHeader || params.getTestedFirstPosition() != sd.firstPosition) {
state.cacheView(i, rowAnchor.view);
break;
}

Expand Down

0 comments on commit 3088e19

Please sign in to comment.