Skip to content

Commit

Permalink
Ensure header layout when the section changes or the old view is null
Browse files Browse the repository at this point in the history
  • Loading branch information
James Smith committed Sep 8, 2012
1 parent 7df5719 commit 570ae75
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static interface PinnedSectionedHeaderAdapter {
private View mCurrentHeader;
private float mHeaderOffset;
private boolean mShouldPin = true;
private int mCurrentSection = 0;

@SuppressWarnings("unused")
public PinnedHeaderListView(Context context) {
Expand Down Expand Up @@ -83,12 +84,12 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
}

private View getHeaderView(int section, View oldView) {
View view;
if (oldView == null) {
view = mAdapter.getSectionHeaderView(section, oldView, this);
boolean shouldLayout = section != mCurrentSection || oldView == null;
View view = mAdapter.getSectionHeaderView(section, oldView, this);
if (shouldLayout) {
// a new section, thus a new header. We should lay it out again
ensurePinnedHeaderLayout(view);
} else {
view = mAdapter.getSectionHeaderView(section, oldView, this);
mCurrentSection = section;
}
return view;
}
Expand Down

0 comments on commit 570ae75

Please sign in to comment.