public class

SimpleWrapperAdapter

extends RecyclerView.Adapter<VH extends RecyclerView.ViewHolder>
implements BridgeAdapterDataObserver.Subscriber WrapperAdapter<VH extends RecyclerView.ViewHolder>
java.lang.Object
   ↳ androidx.recyclerview.widget.RecyclerView.Adapter<VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder>
     ↳ com.h6ah4i.android.widget.advrecyclerview.adapter.SimpleWrapperAdapter<VH extends androidx.recyclerview.widget.RecyclerView.ViewHolder>
Known Direct Subclasses

Class Overview

A simple wrapper class. It just bypasses all methods and events to the wrapped adapter. Use this class as a default implementation of WrapperAdapter, so extend it and override each methods to build your own specialized adapter!

Summary

Fields
protected static final List<Object> FULL_UPDATE_PAYLOADS
Public Constructors
SimpleWrapperAdapter(Adapter<VH> adapter)
Constructor
Public Methods
int getItemCount()
long getItemId(int position)
int getItemViewType(int position)
Adapter<VH> getWrappedAdapter()
Returns underlying adapter.
void getWrappedAdapters(List<Adapter> adapters)
Gets wrapped children adapters.
boolean isWrappedAdapterAlive()
Returns whether the wrapped adapter exists.
void onAttachedToRecyclerView(RecyclerView recyclerView)
void onBindViewHolder(VH holder, int position)
void onBindViewHolder(VH holder, int position, List<Object> payloads)
final void onBridgedAdapterChanged(Adapter source, Object tag)
Routed onChanged() event.
final void onBridgedAdapterItemRangeChanged(Adapter source, Object tag, int positionStart, int itemCount)
final void onBridgedAdapterItemRangeChanged(Adapter sourceAdapter, Object tag, int positionStart, int itemCount, Object payload)
final void onBridgedAdapterItemRangeInserted(Adapter sourceAdapter, Object tag, int positionStart, int itemCount)
final void onBridgedAdapterItemRangeRemoved(Adapter sourceAdapter, Object tag, int positionStart, int itemCount)
final void onBridgedAdapterRangeMoved(Adapter sourceAdapter, Object tag, int fromPosition, int toPosition, int itemCount)
VH onCreateViewHolder(ViewGroup parent, int viewType)
void onDetachedFromRecyclerView(RecyclerView recyclerView)
boolean onFailedToRecycleView(VH holder)
boolean onFailedToRecycleView(VH holder, int viewType)
onFailedToRecycleView() with unwrapped item view type parameter.
void onViewAttachedToWindow(VH holder)
void onViewAttachedToWindow(VH holder, int viewType)
onViewAttachedToWindow() with unwrapped item view type parameter.
void onViewDetachedFromWindow(VH holder)
void onViewDetachedFromWindow(VH holder, int viewType)
onViewDetachedFromWindow() with unwrapped item view type parameter.
void onViewRecycled(VH holder, int viewType)
onViewRecycled() with unwrapped item view type parameter.
void onViewRecycled(VH holder)
void release()
Releases bounded resources.
void setHasStableIds(boolean hasStableIds)
void unwrapPosition(UnwrapPositionResult dest, int position)
Unwraps position.
int wrapPosition(AdapterPathSegment pathSegment, int position)
Wraps position.
Protected Methods
void onHandleWrappedAdapterChanged()
void onHandleWrappedAdapterItemRangeChanged(int positionStart, int itemCount)
void onHandleWrappedAdapterItemRangeChanged(int positionStart, int itemCount, Object payload)
void onHandleWrappedAdapterItemRangeInserted(int positionStart, int itemCount)
void onHandleWrappedAdapterItemRangeRemoved(int positionStart, int itemCount)
void onHandleWrappedAdapterRangeMoved(int fromPosition, int toPosition, int itemCount)
void onRelease()
[Expand]
Inherited Methods
From class androidx.recyclerview.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

protected static final List<Object> FULL_UPDATE_PAYLOADS

Public Constructors

public SimpleWrapperAdapter (Adapter<VH> adapter)

Constructor

Parameters
adapter The adapter which to be wrapped

Public Methods

public int getItemCount ()

public long getItemId (int position)

public int getItemViewType (int position)

public Adapter<VH> getWrappedAdapter ()

Returns underlying adapter.

Returns
  • The underlying adapter instance

public void getWrappedAdapters (List<Adapter> adapters)

Gets wrapped children adapters.

Parameters
adapters The destination

public boolean isWrappedAdapterAlive ()

Returns whether the wrapped adapter exists.

Returns
  • True if underlying adapter is present. Otherwise, false.

public void onAttachedToRecyclerView (RecyclerView recyclerView)

public void onBindViewHolder (VH holder, int position)

public void onBindViewHolder (VH holder, int position, List<Object> payloads)

public final void onBridgedAdapterChanged (Adapter source, Object tag)

Routed onChanged() event.

Parameters
source The source adapter
tag The tag object

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

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 final void onBridgedAdapterItemRangeChanged (Adapter sourceAdapter, Object tag, int positionStart, int itemCount, Object payload)

Parameters
sourceAdapter 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 final void onBridgedAdapterItemRangeInserted (Adapter sourceAdapter, Object tag, int positionStart, int itemCount)

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

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

Parameters
sourceAdapter 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 final void onBridgedAdapterRangeMoved (Adapter sourceAdapter, Object tag, int fromPosition, int toPosition, int itemCount)

Parameters
sourceAdapter 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 VH onCreateViewHolder (ViewGroup parent, int viewType)

public void onDetachedFromRecyclerView (RecyclerView recyclerView)

public boolean onFailedToRecycleView (VH holder)

public boolean onFailedToRecycleView (VH holder, int viewType)

onFailedToRecycleView() with unwrapped item view type parameter.

Parameters
holder The ViewHolder containing the View that could not be recycled due to its transient state.
viewType Unwrapped view type. Use this instead of #{getItemViewType()}.
Returns
  • True if the View should be recycled, false otherwise. Note that if this method returns true, RecyclerView will ignore the transient state of the View and recycle it regardless. If this method returns false, RecyclerView will check the View's transient state again before giving a final decision. Default implementation returns false.

public void onViewAttachedToWindow (VH holder)

public void onViewAttachedToWindow (VH holder, int viewType)

onViewAttachedToWindow() with unwrapped item view type parameter.

Parameters
holder Holder of the view being attached
viewType Unwrapped view type. Use this instead of #{getItemViewType()}.

public void onViewDetachedFromWindow (VH holder)

public void onViewDetachedFromWindow (VH holder, int viewType)

onViewDetachedFromWindow() with unwrapped item view type parameter.

Parameters
holder Holder of the view being detached
viewType Unwrapped view type. Use this instead of #{getItemViewType()}.

public void onViewRecycled (VH holder, int viewType)

onViewRecycled() with unwrapped item view type parameter.

Parameters
holder The ViewHolder for the view being recycled
viewType Unwrapped view type. Use this instead of #{getItemViewType()}.

public void onViewRecycled (VH holder)

public void release ()

Releases bounded resources.

public void setHasStableIds (boolean hasStableIds)

public void unwrapPosition (UnwrapPositionResult dest, int position)

Unwraps position. This method converts the passed wrapped position to child adapter's position.

Parameters
dest The destination
position The wrapped position to be unwrapped

public int wrapPosition (AdapterPathSegment pathSegment, int position)

Wraps position. This method converts the passed child adapter's position to wrapped position.

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 ()

protected void onHandleWrappedAdapterItemRangeChanged (int positionStart, int itemCount)

protected void onHandleWrappedAdapterItemRangeChanged (int positionStart, int itemCount, Object payload)

protected void onHandleWrappedAdapterItemRangeInserted (int positionStart, int itemCount)

protected void onHandleWrappedAdapterItemRangeRemoved (int positionStart, int itemCount)

protected void onHandleWrappedAdapterRangeMoved (int fromPosition, int toPosition, int itemCount)

protected void onRelease ()