Skip to content

Commit

Permalink
Merge pull request #376 from asymptotik/top_offset
Browse files Browse the repository at this point in the history
Fixed layout issues caused when the StickyHeaderTopOffset was set to non...
  • Loading branch information
emilsjolander committed Apr 6, 2015
2 parents c308473 + 3f1b6eb commit db67ab1
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
mList.layout(0, 0, mList.getMeasuredWidth(), getHeight());
if (mHeader != null) {
MarginLayoutParams lp = (MarginLayoutParams) mHeader.getLayoutParams();
int headerTop = lp.topMargin + stickyHeaderTop();
int headerTop = lp.topMargin;
mHeader.layout(mPaddingLeft, headerTop, mHeader.getMeasuredWidth()
+ mPaddingLeft, headerTop + mHeader.getMeasuredHeight());
}
Expand Down Expand Up @@ -349,18 +349,17 @@ private void updateHeader(int headerPosition) {
}
}

int headerOffset = 0;
int headerOffset = stickyHeaderTop();

// Calculate new header offset
// Skip looking at the first view. it never matters because it always
// results in a headerOffset = 0
int headerBottom = mHeader.getMeasuredHeight() + stickyHeaderTop();
for (int i = 0; i < mList.getChildCount(); i++) {
final View child = mList.getChildAt(i);
final boolean doesChildHaveHeader = child instanceof WrapperView && ((WrapperView) child).hasHeader();
final boolean isChildFooter = mList.containsFooterView(child);
if (child.getTop() >= stickyHeaderTop() && (doesChildHaveHeader || isChildFooter)) {
headerOffset = Math.min(child.getTop() - headerBottom, 0);
headerOffset = Math.min(child.getTop() - mHeader.getMeasuredHeight(), headerOffset);
break;
}
}
Expand Down Expand Up @@ -397,12 +396,7 @@ public void onClick(View v) {
// hides the headers in the list under the sticky header.
// Makes sure the other ones are showing
private void updateHeaderVisibilities() {
int top;
if (mHeader != null) {
top = mHeader.getMeasuredHeight() + (mHeaderOffset != null ? mHeaderOffset : 0) + mStickyHeaderTopOffset;
} else {
top = stickyHeaderTop();
}
int top = stickyHeaderTop();
int childCount = mList.getChildCount();
for (int i = 0; i < childCount; i++) {

Expand Down

0 comments on commit db67ab1

Please sign in to comment.