LeanbackListPreferenceDialogFragment.AdapterMulti


public inner class LeanbackListPreferenceDialogFragment.AdapterMulti extends RecyclerView.Adapter implements LeanbackListPreferenceDialogFragment.ViewHolder.OnItemClickListener


Adapter for multiple choices.

Summary

Public constructors

AdapterMulti(
    CharSequence[] entries,
    CharSequence[] entryValues,
    Set<String> initialSelections
)

Public methods

int

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

void

Called by RecyclerView to display the data at the specified position.

LeanbackListPreferenceDialogFragment.ViewHolder
onCreateViewHolder(ViewGroup parent, int viewType)

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

void

Inherited methods

From androidx.recyclerview.widget.RecyclerView.Adapter
final void
bindViewHolder(@NonNull VH holder, int position)

This method internally calls onBindViewHolder to update the ViewHolder contents with the item at the given position and also sets up some private fields to be used by RecyclerView.

final @NonNull VH
createViewHolder(@NonNull ViewGroup parent, int viewType)

This method calls onCreateViewHolder to create a new ViewHolder and initializes some private fields to be used by RecyclerView.

int
findRelativeAdapterPositionIn(
    @NonNull RecyclerView.Adapter<RecyclerView.ViewHolder> adapter,
    @NonNull RecyclerView.ViewHolder viewHolder,
    int localPosition
)

Returns the position of the given ViewHolder in the given Adapter.

long
getItemId(int position)

Return the stable ID for the item at position.

int
getItemViewType(int position)

Return the view type of the item at position for the purposes of view recycling.

final @NonNull RecyclerView.Adapter.StateRestorationPolicy

Returns when this Adapter wants to restore the state.

final boolean

Returns true if one or more observers are attached to this adapter.

final boolean

Returns true if this adapter publishes a unique long value that can act as a key for the item at a given position in the data set.

final void

Notify any registered observers that the data set has changed.

final void
notifyItemChanged(int position)

Notify any registered observers that the item at position has changed.

final void
notifyItemChanged(int position, @Nullable Object payload)

Notify any registered observers that the item at position has changed with an optional payload object.

final void
notifyItemInserted(int position)

Notify any registered observers that the item reflected at position has been newly inserted.

final void
notifyItemMoved(int fromPosition, int toPosition)

Notify any registered observers that the item reflected at fromPosition has been moved to toPosition.

final void
notifyItemRangeChanged(int positionStart, int itemCount)

Notify any registered observers that the itemCount items starting at position positionStart have changed.

final void
notifyItemRangeChanged(
    int positionStart,
    int itemCount,
    @Nullable Object payload
)

Notify any registered observers that the itemCount items starting at position positionStart have changed.

final void
notifyItemRangeInserted(int positionStart, int itemCount)

Notify any registered observers that the currently reflected itemCount items starting at positionStart have been newly inserted.

final void
notifyItemRangeRemoved(int positionStart, int itemCount)

Notify any registered observers that the itemCount items previously located at positionStart have been removed from the data set.

final void
notifyItemRemoved(int position)

Notify any registered observers that the item previously located at position has been removed from the data set.

void

Called by RecyclerView when it starts observing this Adapter.

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

Called by RecyclerView to display the data at the specified position.

void

Called by RecyclerView when it stops observing this Adapter.

boolean

Called by the RecyclerView if a ViewHolder created by this Adapter cannot be recycled due to its transient state.

void

Called when a view created by this adapter has been attached to a window.

void

Called when a view created by this adapter has been detached from its window.

void
onViewRecycled(@NonNull VH holder)

Called when a view created by this adapter has been recycled.

void

Register a new observer to listen for data changes.

void
setHasStableIds(boolean hasStableIds)

Indicates whether each item in the data set can be represented with a unique identifier of type java.lang.Long.

void

Sets the state restoration strategy for the Adapter.

void

Unregister an observer currently listening for data changes.

Public constructors

AdapterMulti

Added in 1.1.0
Deprecated in 1.1.0
public AdapterMulti(
    CharSequence[] entries,
    CharSequence[] entryValues,
    Set<String> initialSelections
)

Public methods

getItemCount

Added in 1.1.0
Deprecated in 1.1.0
public int getItemCount()

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

Returns
int

The total number of items in this adapter.

onBindViewHolder

Added in 1.1.0
Deprecated in 1.1.0
public void onBindViewHolder(
    LeanbackListPreferenceDialogFragment.ViewHolder holder,
    int position
)

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

Note that unlike android.widget.ListView, RecyclerView will not call this method again if the position of the item changes in the data set unless the item itself is invalidated or the new position cannot be determined. For this reason, you should only use the position parameter while acquiring the related data item inside this method and should not keep a copy of it. If you need the position of an item later on (e.g. in a click listener), use getBindingAdapterPosition which will have the updated adapter position. Override onBindViewHolder instead if Adapter can handle efficient partial bind.

Parameters
LeanbackListPreferenceDialogFragment.ViewHolder holder

The ViewHolder which should be updated to represent the contents of the item at the given position in the data set.

int position

The position of the item within the adapter's data set.

onCreateViewHolder

Added in 1.1.0
Deprecated in 1.1.0
public LeanbackListPreferenceDialogFragment.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)

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

This new ViewHolder should be constructed with a new View that can represent the items of the given type. You can either create a new View manually or inflate it from an XML layout file.

The new ViewHolder will be used to display items of the adapter using onBindViewHolder. Since it will be re-used to display different items in the data set, it is a good idea to cache references to sub views of the View to avoid unnecessary findViewById calls.

Parameters
ViewGroup parent

The ViewGroup into which the new View will be added after it is bound to an adapter position.

int viewType

The view type of the new View.

Returns
LeanbackListPreferenceDialogFragment.ViewHolder

A new ViewHolder that holds a View of the given view type.

onItemClick

Added in 1.2.0-alpha04
Deprecated in 1.2.0-alpha04
public void onItemClick(
    LeanbackListPreferenceDialogFragment.ViewHolder viewHolder
)