public abstract class

AbstractHeaderFooterWrapperAdapter

extends ComposedAdapter
java.lang.Object
   ↳ android.support.v7.widget.RecyclerView.Adapter<VH extends android.support.v7.widget.RecyclerView.ViewHolder>
     ↳ com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter
       ↳ com.h6ah4i.android.widget.advrecyclerview.headerfooter.AbstractHeaderFooterWrapperAdapter<HeaderVH extends android.support.v7.widget.RecyclerView.ViewHolder, FooterVH extends android.support.v7.widget.RecyclerView.ViewHolder>

Class Overview

A simplified version of ComposedAdapter for creating headers and footers.

Summary

Nested Classes
class AbstractHeaderFooterWrapperAdapter.BaseFooterAdapter  
class AbstractHeaderFooterWrapperAdapter.BaseHeaderAdapter  
Constants
int SEGMENT_TYPE_FOOTER Segment type: footer items
int SEGMENT_TYPE_HEADER Segment type: header items
int SEGMENT_TYPE_NORMAL Segment type: normal items
[Expand]
Inherited Fields
From class com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter
Public Constructors
AbstractHeaderFooterWrapperAdapter()
Constructor
Public Methods
Adapter getFooterAdapter()
Returns the adapter for the footer items.
abstract int getFooterItemCount()
Returns the total number of items in the data set hold by the footer adapter.
long getFooterItemId(int localPosition)
Return the stable ID for the item at localPosition.
int getFooterItemViewType(int localPosition)
Return the view type of the footer item at localPosition for the purposes of view recycling.
AdapterPathSegment getFooterSegment()
Returns the path segment for the footer adapter.
Adapter getHeaderAdapter()
Returns the adapter for the header items.
abstract int getHeaderItemCount()
Returns the total number of items in the data set hold by the header adapter.
long getHeaderItemId(int localPosition)
Return the stable ID for the item at localPosition.
int getHeaderItemViewType(int localPosition)
Return the view type of the header item at localPosition for the purposes of view recycling.
AdapterPathSegment getHeaderSegment()
Returns the path segment for the header adapter.
Adapter getWrappedAdapter()
Returns underlying adapter.
AdapterPathSegment getWrappedAdapterSegment()
Returns the path segment for the underlying adapter.
void onBindFooterItemViewHolder(FooterVH holder, int localPosition, List<Object> payloads)
Called by RecyclerView to display the data at the specified position.
abstract void onBindFooterItemViewHolder(FooterVH holder, int localPosition)
Called by RecyclerView to display the data at the specified position.
void onBindHeaderItemViewHolder(HeaderVH holder, int localPosition, List<Object> payloads)
Called by RecyclerView to display the data at the specified position.
abstract void onBindHeaderItemViewHolder(HeaderVH holder, int localPosition)
Called by RecyclerView to display the data at the specified position.
abstract FooterVH onCreateFooterItemViewHolder(ViewGroup parent, int viewType)
Called when RecyclerView needs a new RecyclerView.ViewHolder of the given type to represent a footer item.
abstract HeaderVH onCreateHeaderItemViewHolder(ViewGroup parent, int viewType)
Called when RecyclerView needs a new RecyclerView.ViewHolder of the given type to represent a header item.
AbstractHeaderFooterWrapperAdapter setAdapter(Adapter<? extends RecyclerView.ViewHolder> adapter)
Protected Methods
Adapter onCreateFooterAdapter()
Returns a newly created adapter for the footer items.
Adapter onCreateHeaderAdapter()
Returns a newly created adapter for header items.
void onRelease()
Implementation of the release() method.
[Expand]
Inherited Methods
From class com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter
From class android.support.v7.widget.RecyclerView.Adapter
From class java.lang.Object
From interface com.h6ah4i.android.widget.advrecyclerview.adapter.BridgeAdapterDataObserver.Subscriber
From interface com.h6ah4i.android.widget.advrecyclerview.adapter.WrappedAdapter
From interface com.h6ah4i.android.widget.advrecyclerview.adapter.WrapperAdapter

Constants

public static final int SEGMENT_TYPE_FOOTER

Segment type: footer items

Constant Value: 2 (0x00000002)

public static final int SEGMENT_TYPE_HEADER

Segment type: header items

Constant Value: 0 (0x00000000)

public static final int SEGMENT_TYPE_NORMAL

Segment type: normal items

Constant Value: 1 (0x00000001)

Public Constructors

public AbstractHeaderFooterWrapperAdapter ()

Constructor

Public Methods

public Adapter getFooterAdapter ()

Returns the adapter for the footer items.

Returns
  • Adapter for the footer items

public abstract int getFooterItemCount ()

Returns the total number of items in the data set hold by the footer adapter.

Returns
  • The total number of items in the footer adapter.
See Also
  • {@link RecyclerView.Adapter#getItemCount()}

public long getFooterItemId (int localPosition)

Return the stable ID for the item at localPosition. If hasStableIds() would return false this method should return NO_ID.

Parameters
localPosition Foote adapter position to query
Returns
  • the stable ID of the item at position
See Also
  • {@link RecyclerView.Adapter#getItemId(int)}

public int getFooterItemViewType (int localPosition)

Return the view type of the footer item at localPosition for the purposes of view recycling.

The default implementation of this method returns 0, making the assumption of a single view type for the adapter. Unlike ListView adapters, types need not be contiguous.

Parameters
localPosition The footer adapter local position to query
Returns
  • integer value identifying the type of the view needed to represent the item at localPosition. Type codes need not be contiguous.

public AdapterPathSegment getFooterSegment ()

Returns the path segment for the footer adapter.

Returns
  • AdapterPathSegment for the footer adapter

public Adapter getHeaderAdapter ()

Returns the adapter for the header items.

Returns
  • Adapter for the header items

public abstract int getHeaderItemCount ()

Returns the total number of items in the data set hold by the header adapter.

Returns
  • The total number of items in the header adapter.
See Also
  • {@link RecyclerView.Adapter#getItemCount()}

public long getHeaderItemId (int localPosition)

Return the stable ID for the item at localPosition. If hasStableIds() would return false this method should return NO_ID.

Parameters
localPosition Header adapter position to query
Returns
  • the stable ID of the item at position
See Also
  • {@link RecyclerView.Adapter#getItemId(int)}

public int getHeaderItemViewType (int localPosition)

Return the view type of the header item at localPosition for the purposes of view recycling.

The default implementation of this method returns 0, making the assumption of a single view type for the adapter. Unlike ListView adapters, types need not be contiguous.

Parameters
localPosition The header adapter local position to query
Returns
  • integer value identifying the type of the view needed to represent the item at localPosition. Type codes need not be contiguous.

public AdapterPathSegment getHeaderSegment ()

Returns the path segment for the header adapter.

Returns
  • AdapterPathSegment for the header adapter

public Adapter getWrappedAdapter ()

Returns underlying adapter.

Returns
  • The underlying adapter instance

public AdapterPathSegment getWrappedAdapterSegment ()

Returns the path segment for the underlying adapter.

Returns
  • AdapterPathSegment for the wrapped adapter

public void onBindFooterItemViewHolder (FooterVH holder, int localPosition, List<Object> payloads)

Called by RecyclerView to display the data at the specified position. This method should update the contents of the itemView to reflect the footer item at the given position.

Parameters
holder The ViewHolder which should be updated to represent the contents of the item at the given position in the data set.
localPosition The position of the item within the footer adapter's data set.
payloads A non-null list of merged payloads. Can be empty list if requires full update.
See Also
  • {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List)}

public abstract void onBindFooterItemViewHolder (FooterVH holder, int localPosition)

Called by RecyclerView to display the data at the specified position. This method should update the contents of the itemView to reflect the footer item at the given position.

Parameters
holder The ViewHolder which should be updated to represent the contents of the item at the given position in the data set.
localPosition The position of the item within the footer adapter's data set.
See Also
  • {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}

public void onBindHeaderItemViewHolder (HeaderVH holder, int localPosition, List<Object> payloads)

Called by RecyclerView to display the data at the specified position. This method should update the contents of the itemView to reflect the header item at the given position.

Parameters
holder The ViewHolder which should be updated to represent the contents of the item at the given position in the data set.
localPosition The position of the item within the header adapter's data set.
payloads A non-null list of merged payloads. Can be empty list if requires full update.
See Also
  • {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int, List)}

public abstract void onBindHeaderItemViewHolder (HeaderVH holder, int localPosition)

Called by RecyclerView to display the data at the specified position. This method should update the contents of the itemView to reflect the header item at the given position.

Parameters
holder The ViewHolder which should be updated to represent the contents of the item at the given position in the data set.
localPosition The position of the item within the header adapter's data set.
See Also
  • {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}

public abstract FooterVH onCreateFooterItemViewHolder (ViewGroup parent, int viewType)

Called when RecyclerView needs a new RecyclerView.ViewHolder of the given type to represent a footer item.

Parameters
parent The ViewGroup into which the new View will be added after it is bound to a footer adapter position.
viewType The view type of the new footer View.
Returns
  • A new ViewHolder for the footer that holds a View of the given view type.
See Also
  • {@link RecyclerView.Adapter#onCreateViewHolder(ViewGroup, int)}
  • {@link #getFooterItemViewType(int)}
  • {@link #onBindFooterItemViewHolder(RecyclerView.ViewHolder, int)}

public abstract HeaderVH onCreateHeaderItemViewHolder (ViewGroup parent, int viewType)

Called when RecyclerView needs a new RecyclerView.ViewHolder of the given type to represent a header item.

Parameters
parent The ViewGroup into which the new View will be added after it is bound to a header adapter position.
viewType The view type of the new header View.
Returns
  • A new ViewHolder for the header that holds a View of the given view type.
See Also
  • {@link RecyclerView.Adapter#onCreateViewHolder(ViewGroup, int)}
  • {@link #getHeaderItemViewType(int)}
  • {@link #onBindHeaderItemViewHolder(RecyclerView.ViewHolder, int)}

public AbstractHeaderFooterWrapperAdapter setAdapter (Adapter<? extends RecyclerView.ViewHolder> adapter)

Parameters
adapter Wrapped contents adapter.

Protected Methods

protected Adapter onCreateFooterAdapter ()

Returns a newly created adapter for the footer items.

Returns
  • Adapter for the footer items

protected Adapter onCreateHeaderAdapter ()

Returns a newly created adapter for header items.

Returns
  • Adapter for header items

protected void onRelease ()

Implementation of the release() method.