Skip to content
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
*.ipr
*.classpath
*.project


build.xml
proguard-project.txt
4 changes: 4 additions & 0 deletions library/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
int section = mAdapter.getSectionForPosition(firstVisibleItem);
int viewType = mAdapter.getSectionHeaderViewType(section);
mCurrentHeader = getSectionHeaderView(section, mCurrentHeaderViewType != viewType ? null : mCurrentHeader);
ensurePinnedHeaderLayout(mCurrentHeader);
ensurePinnedHeaderLayout(mCurrentHeader, false);
mCurrentHeaderViewType = viewType;

mHeaderOffset = 0.0f;
Expand Down Expand Up @@ -115,14 +115,14 @@ private View getSectionHeaderView(int section, View oldView) {
View view = mAdapter.getSectionHeaderView(section, oldView, this);
if (shouldLayout) {
// a new section, thus a new header. We should lay it out again
ensurePinnedHeaderLayout(view);
ensurePinnedHeaderLayout(view, false);
mCurrentSection = section;
}
return view;
}

private void ensurePinnedHeaderLayout(View header) {
if (header.isLayoutRequested()) {
private void ensurePinnedHeaderLayout(View header, boolean forceLayout) {
if (header.isLayoutRequested() || forceLayout) {
int widthSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY);
int heightSpec;
ViewGroup.LayoutParams layoutParams = header.getLayoutParams();
Expand All @@ -140,13 +140,11 @@ private void ensurePinnedHeaderLayout(View header) {
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mAdapter == null || !mShouldPin || mCurrentHeader == null) return;
if (mAdapter == null || !mShouldPin || mCurrentHeader == null)
return;
int saveCount = canvas.save();
canvas.translate(0, mHeaderOffset);
canvas.clipRect(0, 0, getWidth(), mCurrentHeader.getMeasuredHeight()); // needed
// for
// <
// HONEYCOMB
canvas.clipRect(0, 0, getWidth(), mCurrentHeader.getMeasuredHeight()); // needed for < HONEYCOMB
mCurrentHeader.draw(canvas);
canvas.restoreToCount(saveCount);
}
Expand Down Expand Up @@ -185,4 +183,10 @@ public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition,
public abstract void onSectionClick(AdapterView<?> adapterView, View view, int section, long id);

}

public void invalidateHeader() {
if (mCurrentHeader != null) {
ensurePinnedHeaderLayout(mCurrentHeader, true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public int getSectionHeaderViewTypeCount() {

public abstract long getItemId(int section, int position);

public abstract Object getSectionItem(int section);

public abstract int getSectionCount();

public abstract int getCountForSection(int section);
Expand Down