Skip to content

Commit

Permalink
fixed all the scrollToPosition methods
Browse files Browse the repository at this point in the history
Now the correctly scroll to the correct position without overlaying the
header.
  • Loading branch information
emilsjolander committed Oct 24, 2013
1 parent 1ae70b0 commit 2e6633f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public void onHeaderClick(View header, int itemPosition, long headerId) {

private boolean isStartOfSection(int position) {
return position == 0
|| mAdapter.getHeaderId(position) == mAdapter
|| mAdapter.getHeaderId(position) != mAdapter
.getHeaderId(position - 1);
}

Expand Down Expand Up @@ -710,6 +710,7 @@ public void smoothScrollToPosition(int position) {
mList.smoothScrollToPosition(position);
} else {
int offset = mAdapter == null ? 0 : getHeaderOverlap(position);
offset -= mClippingToPadding ? 0 : mPaddingTop;
mList.smoothScrollToPositionFromTop(position, offset);
}
}
Expand All @@ -724,6 +725,7 @@ public void smoothScrollToPosition(int position, int boundPosition) {
public void smoothScrollToPositionFromTop(int position, int offset) {
requireSdkVersion(Build.VERSION_CODES.HONEYCOMB);
offset += mAdapter == null ? 0 : getHeaderOverlap(position);
offset -= mClippingToPadding ? 0 : mPaddingTop;
mList.smoothScrollToPositionFromTop(position, offset);
}

Expand All @@ -732,6 +734,7 @@ public void smoothScrollToPositionFromTop(int position, int offset,
int duration) {
requireSdkVersion(Build.VERSION_CODES.HONEYCOMB);
offset += mAdapter == null ? 0 : getHeaderOverlap(position);
offset -= mClippingToPadding ? 0 : mPaddingTop;
mList.smoothScrollToPositionFromTop(position, offset, duration);
}

Expand All @@ -745,6 +748,7 @@ public void setSelectionAfterHeaderView() {

public void setSelectionFromTop(int position, int y) {
y += mAdapter == null ? 0 : getHeaderOverlap(position);
y -= mClippingToPadding ? 0 : mPaddingTop;
mList.setSelectionFromTop(position, y);
}

Expand Down

0 comments on commit 2e6633f

Please sign in to comment.