Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible to reuse the header view when sticky and when not #340

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d50f23c
possible to reuse the header view when sticky and when not
farfromrefug Oct 5, 2014
04a0d91
take list headers into account
farfromrefug Oct 6, 2014
3f58b8c
take list headers into account
farfromrefug Oct 6, 2014
6913cf6
allow null item, Useful to show empty section but still show the header
farfromrefug Oct 6, 2014
05ee7f5
newHeader should be the added one
farfromrefug Oct 6, 2014
5ab69ec
if the listview has headers make sure the headerPosition is >= 0
farfromrefug Oct 6, 2014
dd2ff3a
Merge branch 'master' of github.com:Akylas/StickyListHeaders into reu…
farfromrefug Oct 6, 2014
bb6647b
the max has to be done at the end
farfromrefug Oct 6, 2014
3f92b12
Merge branch 'master' of github.com:Akylas/StickyListHeaders into reu…
farfromrefug Oct 6, 2014
391c17c
only set listener if mOnHeaderClickListener != null
farfromrefug Oct 6, 2014
ce7b5fe
in case we need it
farfromrefug Oct 6, 2014
40135ad
the case child.getTop() == stickyHeaderTop() is bad because it would
farfromrefug Oct 6, 2014
38230f1
reset mHeader transform when swaping so that if it is reused
farfromrefug Oct 6, 2014
79ebfca
reset mHeader transform when swaping so that if it is reused
farfromrefug Oct 6, 2014
dfe1da5
Refactoring to allow better use with ListViewAnimations
farfromrefug Oct 14, 2014
69798e2
abstract StickyListHeadersListViewAbstract to custom mList class
farfromrefug Oct 15, 2014
3e27671
fix measure so that it animates correctly
farfromrefug Oct 15, 2014
d976814
Merge remote-tracking branch 'origin/master' into reuse_header
farfromrefug Oct 15, 2014
24ad273
abstract listview interface (in case we want to use a gridview)
farfromrefug Feb 1, 2015
b011bc7
grid list view adapter!
farfromrefug Feb 1, 2015
b6e13eb
should extend listview
farfromrefug Mar 19, 2015
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
@@ -0,0 +1,18 @@
package se.emilsjolander.stickylistheaders;

import android.view.View;

public interface AbsListViewHeadersSupport {
public void addHeaderView(View v, Object data, boolean isSelectable);
public void addHeaderView(View v);
public int getHeaderViewsCount();
public boolean removeHeaderView(View v);
public void addFooterView(View v, Object data, boolean isSelectable);
public void addFooterView(View v);
public int getFooterViewsCount();
public boolean removeFooterView(View v);

public void smoothScrollByOffset(int offset);
public void setSelectionAfterHeaderView();
public void setSelectionFromTop(int position, int y);
}
26 changes: 15 additions & 11 deletions library/src/se/emilsjolander/stickylistheaders/AdapterWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Jake Wharton ([email protected])
*/
class AdapterWrapper extends BaseAdapter implements StickyListHeadersAdapter {
public class AdapterWrapper extends BaseAdapter implements StickyListHeadersAdapter {

interface OnHeaderClickListener {
void onHeaderClick(View header, int itemPosition, long headerId);
Expand Down Expand Up @@ -61,6 +61,10 @@ void setDivider(Drawable divider, int dividerHeight) {
this.mDividerHeight = dividerHeight;
notifyDataSetChanged();
}

public StickyListHeadersAdapter getDelegate() {
return mDelegate;
}

@Override
public boolean areAllItemsEnabled() {
Expand Down Expand Up @@ -131,16 +135,16 @@ private View configureHeader(WrapperView wv, final int position) {
}
//if the header isn't clickable, the listselector will be drawn on top of the header
header.setClickable(true);
header.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if(mOnHeaderClickListener != null){
long headerId = mDelegate.getHeaderId(position);
mOnHeaderClickListener.onHeaderClick(v, position, headerId);
}
}
});
if(mOnHeaderClickListener != null) {
header.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
long headerId = mDelegate.getHeaderId(position);
mOnHeaderClickListener.onHeaderClick(v, position, headerId);
}
});
}
return header;
}

Expand Down
Loading