Skip to content

Commit

Permalink
Merge pull request #51 from starkej2/fix-optional-headers-performance
Browse files Browse the repository at this point in the history
Remove unnecessary iterations over adapter items when determining whether to show a header
  • Loading branch information
ebarrenechea authored Oct 13, 2016
2 parents 44aec5a + c6b10d4 commit 033a22a
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,7 @@ private boolean showHeaderAboveItem(int itemAdapterPosition) {
if (itemAdapterPosition == 0) {
return true;
}

for (int pos = itemAdapterPosition; pos >= 0; pos--) {
long posHeaderId = mAdapter.getHeaderId(pos);

if (posHeaderId != mAdapter.getHeaderId(itemAdapterPosition)) {
if (pos + 1 == itemAdapterPosition) {
return true;
}
}
}
return false;
return mAdapter.getHeaderId(itemAdapterPosition - 1) != mAdapter.getHeaderId(itemAdapterPosition);
}

/**
Expand Down

0 comments on commit 033a22a

Please sign in to comment.