public class

ComposedAdapter

extends RecyclerView.Adapter<VH extends RecyclerView.ViewHolder>
implements BridgeAdapterDataObserver.Subscriber WrapperAdapter<VH extends RecyclerView.ViewHolder>
java.lang.Object
   ↳ android.support.v7.widget.RecyclerView.Adapter<VH extends android.support.v7.widget.RecyclerView.ViewHolder>
     ↳ com.h6ah4i.android.widget.advrecyclerview.composedadapter.ComposedAdapter
Known Direct Subclasses

Class Overview

A wrapper adapter which can compose and manage several children adapters.

Summary

Fields
public static long NO_SEGMENTED_POSITION Corresponding segmented position value of NO_POSITION.
Public Constructors
ComposedAdapter()
Constructor.
Public Methods
ComposedChildAdapterTag addAdapter(Adapter adapter, int position)
Adda child adapter to the specified position.
ComposedChildAdapterTag addAdapter(Adapter adapter)
Add a child adapter to the tail.
static int extractSegmentOffsetPart(long segmentedPosition)
Returns the offset value extracted from a segmented position.
static int extractSegmentPart(long segmentedPosition)
Returns the segment value extracted from a segmented position.
int getChildAdapterCount()
Returns the total number of children adapters.
int getItemCount()
{@lineritDoc }
long getItemId(int position)
int getItemViewType(int position)
{@lineritDoc }
int getSegment(ComposedChildAdapterTag tag)
Returns the assigned segment number.
long getSegmentedPosition(int flatPosition)
Gets a "segmented position".
void getWrappedAdapters(List<Adapter> adapters)
Gets wrapped children adapters.
void onAttachedToRecyclerView(RecyclerView recyclerView)
{@lineritDoc }
void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List<Object> payloads)
{@lineritDoc }
void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
{@lineritDoc }
void onBridgedAdapterChanged(Adapter source, Object tag)
{@lineritDoc }
void onBridgedAdapterItemRangeChanged(Adapter source, Object tag, int positionStart, int itemCount, Object payload)
{@lineritDoc }
void onBridgedAdapterItemRangeChanged(Adapter source, Object tag, int positionStart, int itemCount)
{@lineritDoc }
void onBridgedAdapterItemRangeInserted(Adapter source, Object tag, int positionStart, int itemCount)
{@lineritDoc }
void onBridgedAdapterItemRangeRemoved(Adapter source, Object tag, int positionStart, int itemCount)
{@lineritDoc }
void onBridgedAdapterRangeMoved(Adapter source, Object tag, int fromPosition, int toPosition, int itemCount)
{@lineritDoc }
RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{@lineritDoc }
void onDetachedFromRecyclerView(RecyclerView recyclerView)
{@lineritDoc }
boolean onFailedToRecycleView(RecyclerView.ViewHolder holder, int viewType)
{@lineritDoc }
boolean onFailedToRecycleView(RecyclerView.ViewHolder holder)
{@lineritDoc }
void onViewAttachedToWindow(RecyclerView.ViewHolder holder)
{@lineritDoc }
void onViewAttachedToWindow(RecyclerView.ViewHolder holder, int viewType)
{@lineritDoc }
void onViewDetachedFromWindow(RecyclerView.ViewHolder holder, int viewType)
{@lineritDoc }
void onViewDetachedFromWindow(RecyclerView.ViewHolder holder)
{@lineritDoc }
void onViewRecycled(RecyclerView.ViewHolder holder, int viewType)
{@lineritDoc }
void onViewRecycled(RecyclerView.ViewHolder holder)
{@lineritDoc }
void release()
Releases bounded resources.
boolean removeAdapter(ComposedChildAdapterTag tag)
Remove a child adapter.
void setHasStableIds(boolean hasStableIds)
{@liheritDoc }
void unwrapPosition(UnwrapPositionResult dest, int position)
{@lineritDoc }
int wrapPosition(AdapterPathSegment pathSegment, int position)
{@lineritDoc }
Protected Methods
void onHandleWrappedAdapterChanged(Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags)
void onHandleWrappedAdapterItemRangeChanged(Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount, Object payload)
void onHandleWrappedAdapterItemRangeChanged(Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount)
void onHandleWrappedAdapterItemRangeInserted(Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount)
void onHandleWrappedAdapterItemRangeRemoved(Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount)
void onHandleWrappedAdapterRangeMoved(Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localFromPosition, int localToPosition, int itemCount)
void onRelease()
Implementation of the release() method.
[Expand]
Inherited Methods
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

Fields

public static long NO_SEGMENTED_POSITION

Corresponding segmented position value of NO_POSITION.

Public Constructors

public ComposedAdapter ()

Constructor.

Public Methods

public ComposedChildAdapterTag addAdapter (Adapter adapter, int position)

Adda child adapter to the specified position.

Parameters
adapter The adapter which to be managed by the ComposedAdapter
position The position inserting a child adapter
Returns
See Also
  • {@link #addAdapter(RecyclerView.Adapter)}

public ComposedChildAdapterTag addAdapter (Adapter adapter)

Add a child adapter to the tail.

This method can be invoked before attaching (= call setAdapter(RecyclerView.Adapter)) to RecyclerView. Also it may throws an IllegalStateException if the ComposedAdapter has been configured to support stable IDs,

Parameters
adapter The adapter which to be managed by the ComposedAdapter
Returns
See Also
  • {@link #addAdapter(RecyclerView.Adapter, int)}

public static int extractSegmentOffsetPart (long segmentedPosition)

Returns the offset value extracted from a segmented position.

Parameters
segmentedPosition The segment position value to be converted
Returns
  • offset part

public static int extractSegmentPart (long segmentedPosition)

Returns the segment value extracted from a segmented position.

Parameters
segmentedPosition The segment position value to be converted
Returns
  • segment part

public int getChildAdapterCount ()

Returns the total number of children adapters.

Returns
  • The total number of children adapters

public int getItemCount ()

{@lineritDoc }

public long getItemId (int position)

public int getItemViewType (int position)

{@lineritDoc }

public int getSegment (ComposedChildAdapterTag tag)

Returns the assigned segment number.

Parameters
tag The tag object linked to a child adapter
Returns
  • Number of the assigned segment

public long getSegmentedPosition (int flatPosition)

Gets a "segmented position".

The segmented position is a packed long value which contains "segment" and "offset inside of the segment" information.

Parameters
flatPosition The normal flat position to be converted
Returns
  • Segmented Position
See Also
  • {@link #extractSegmentPart(long)}
  • {@link #extractSegmentOffsetPart(long)}

public void getWrappedAdapters (List<Adapter> adapters)

Gets wrapped children adapters.

Parameters
adapters The destination

public void onAttachedToRecyclerView (RecyclerView recyclerView)

{@lineritDoc }

public void onBindViewHolder (RecyclerView.ViewHolder holder, int position, List<Object> payloads)

{@lineritDoc }

public void onBindViewHolder (RecyclerView.ViewHolder holder, int position)

{@lineritDoc }

public void onBridgedAdapterChanged (Adapter source, Object tag)

{@lineritDoc }

Parameters
source The source adapter
tag The tag object

public void onBridgedAdapterItemRangeChanged (Adapter source, Object tag, int positionStart, int itemCount, Object payload)

{@lineritDoc }

Parameters
source The source adapter
tag The tag object
positionStart Position of the first item that has changed
itemCount Number of items that have changed
payload Optional parameter, use null to identify a "full" update

public void onBridgedAdapterItemRangeChanged (Adapter source, Object tag, int positionStart, int itemCount)

{@lineritDoc }

Parameters
source The source adapter
tag The tag object
positionStart Position of the first item that has changed
itemCount Number of items that have changed

public void onBridgedAdapterItemRangeInserted (Adapter source, Object tag, int positionStart, int itemCount)

{@lineritDoc }

Parameters
source The source adapter
tag The tag object
positionStart Position of the first item that was inserted
itemCount Number of items inserted

public void onBridgedAdapterItemRangeRemoved (Adapter source, Object tag, int positionStart, int itemCount)

{@lineritDoc }

Parameters
source The source adapter
tag The tag object
positionStart Previous position of the first item that was removed
itemCount Number of items removed from the data set

public void onBridgedAdapterRangeMoved (Adapter source, Object tag, int fromPosition, int toPosition, int itemCount)

{@lineritDoc }

Parameters
source The source adapter
tag The tag object
fromPosition Previous position of the item.
toPosition New position of the item.
itemCount Number of items moved (NOTE: this parameter is not actually used, always 1.)

public RecyclerView.ViewHolder onCreateViewHolder (ViewGroup parent, int viewType)

{@lineritDoc }

public void onDetachedFromRecyclerView (RecyclerView recyclerView)

{@lineritDoc }

public boolean onFailedToRecycleView (RecyclerView.ViewHolder holder, int viewType)

{@lineritDoc }

public boolean onFailedToRecycleView (RecyclerView.ViewHolder holder)

{@lineritDoc }

public void onViewAttachedToWindow (RecyclerView.ViewHolder holder)

{@lineritDoc }

public void onViewAttachedToWindow (RecyclerView.ViewHolder holder, int viewType)

{@lineritDoc }

public void onViewDetachedFromWindow (RecyclerView.ViewHolder holder, int viewType)

{@lineritDoc }

public void onViewDetachedFromWindow (RecyclerView.ViewHolder holder)

{@lineritDoc }

public void onViewRecycled (RecyclerView.ViewHolder holder, int viewType)

{@lineritDoc }

public void onViewRecycled (RecyclerView.ViewHolder holder)

{@lineritDoc }

public void release ()

Releases bounded resources.

public boolean removeAdapter (ComposedChildAdapterTag tag)

Remove a child adapter.

Parameters
tag The tag object linked to a child adapter to be removed
Returns
  • True if the child adapter is removed. Otherwise false.

public void setHasStableIds (boolean hasStableIds)

{@liheritDoc }

public void unwrapPosition (UnwrapPositionResult dest, int position)

{@lineritDoc }

Parameters
dest The destination
position The wrapped position to be unwrapped

public int wrapPosition (AdapterPathSegment pathSegment, int position)

{@lineritDoc }

Parameters
pathSegment The path segment of the child adapter
position The child adapter's position to be wrapped
Returns
  • Wrapped position

Protected Methods

protected void onHandleWrappedAdapterChanged (Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags)

protected void onHandleWrappedAdapterItemRangeChanged (Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount, Object payload)

protected void onHandleWrappedAdapterItemRangeChanged (Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount)

protected void onHandleWrappedAdapterItemRangeInserted (Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount)

protected void onHandleWrappedAdapterItemRangeRemoved (Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localPositionStart, int itemCount)

protected void onHandleWrappedAdapterRangeMoved (Adapter sourceAdapter, List<ComposedChildAdapterTag> sourceTags, int localFromPosition, int localToPosition, int itemCount)

protected void onRelease ()

Implementation of the release() method.