Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
Expand Down Expand Up @@ -33,6 +34,7 @@ public static interface PinnedSectionedHeaderAdapter {
private int mCurrentSection = 0;
private int mWidthMode;
private int mHeightMode;
private int firstVisibleItem;

public PinnedHeaderListView(Context context) {
super(context);
Expand Down Expand Up @@ -77,7 +79,7 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
}
return;
}

this.firstVisibleItem = firstVisibleItem;
firstVisibleItem -= getHeaderViewsCount();

int section = mAdapter.getSectionForPosition(firstVisibleItem);
Expand All @@ -96,7 +98,7 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
header.setVisibility(VISIBLE);
if (pinnedHeaderHeight >= headerTop && headerTop > 0) {
mHeaderOffset = headerTop - header.getHeight();
} else if (headerTop <= 0) {
} else if (headerTop < 0) {
header.setVisibility(INVISIBLE);
}
}
Expand Down Expand Up @@ -145,14 +147,21 @@ protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
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
mCurrentHeader.draw(canvas);
canvas.restoreToCount(saveCount);
//no headerview
if(firstVisibleItem==0&&getChildAt(firstVisibleItem)!=null&&
getChildAt(firstVisibleItem).getTop()>=0){
return;
}else{
int saveCount = canvas.save();
canvas.translate(0, mHeaderOffset);
canvas.clipRect(0, 0, getWidth(), mCurrentHeader.getMeasuredHeight()); // needed
// for
// <
// HONEYCOMB
mCurrentHeader.draw(canvas);
canvas.restoreToCount(saveCount);
}

}

@Override
Expand Down