Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Add position param to onCreateHeaderViewHolder #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -20,9 +20,10 @@ public interface StickyRecyclerHeadersAdapter<VH extends RecyclerView.ViewHolder
* to inflate the layout for the header.
*
* @param parent the view to create a header view holder for
* @param position the position of the item to create the view holder for.
* @return the view holder
*/
VH onCreateHeaderViewHolder(ViewGroup parent);
VH onCreateHeaderViewHolder(ViewGroup parent, int position);

/**
* Binds an existing ViewHolder to the specified adapter position.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public View getHeader(RecyclerView parent, int position) {
View header = mHeaderViews.get(headerId);
if (header == null) {
//TODO - recycle views
RecyclerView.ViewHolder viewHolder = mAdapter.onCreateHeaderViewHolder(parent);
RecyclerView.ViewHolder viewHolder = mAdapter.onCreateHeaderViewHolder(parent, position);
mAdapter.onBindHeaderViewHolder(viewHolder, position);
header = viewHolder.itemView;
if (header.getLayoutParams() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public long getHeaderId(int position) {
}

@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent, int position) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.view_header, parent, false);
return new RecyclerView.ViewHolder(view) {
Expand Down