public class GuidedActionAdapter extends RecyclerView.Adapter
GuidedActionsStylist
, while clients are notified of interactions via
GuidedActionAdapter.ClickListener
and GuidedActionAdapter.FocusListener
.Modifier and Type | Class and Description |
---|---|
static interface |
GuidedActionAdapter.ClickListener
Object listening for click events within a
GuidedActionAdapter . |
static interface |
GuidedActionAdapter.EditListener
Object listening for edit events within a
GuidedActionAdapter . |
static interface |
GuidedActionAdapter.FocusListener
Object listening for focus events within a
GuidedActionAdapter . |
Constructor and Description |
---|
GuidedActionAdapter(List<GuidedAction> actions,
GuidedActionAdapter.ClickListener clickListener,
GuidedActionAdapter.FocusListener focusListener,
GuidedActionsStylist presenter,
boolean isSubAdapter)
Constructs a GuidedActionAdapter with the given list of guided actions, the given click and
focus listeners, and the given presenter.
|
Modifier and Type | Method and Description |
---|---|
GuidedActionsStylist.ViewHolder |
findSubChildViewHolder(View v) |
List<GuidedAction> |
getActions()
Used for serialization only.
|
int |
getCount()
Returns the count of actions managed by this adapter.
|
GuidedActionsStylist |
getGuidedActionsStylist() |
GuidedAction |
getItem(int position)
Returns the GuidedAction at the given position in the managed list.
|
int |
getItemCount()
Returns the total number of items in the data set held by the adapter.
|
int |
getItemViewType(int position)
Return the view type of the item at
position for the purposes
of view recycling. |
void |
handleCheckedActions(GuidedActionsStylist.ViewHolder avh) |
int |
indexOf(GuidedAction action)
Return index of action in array
|
void |
onBindViewHolder(RecyclerView.ViewHolder holder,
int position)
Called by RecyclerView to display the data at the specified position.
|
RecyclerView.ViewHolder |
onCreateViewHolder(ViewGroup parent,
int viewType)
Called when RecyclerView needs a new
RecyclerView.ViewHolder of the given type to represent
an item. |
void |
performOnActionClick(GuidedActionsStylist.ViewHolder avh) |
void |
setActions(List<GuidedAction> actions)
Sets the list of actions managed by this adapter.
|
void |
setClickListener(GuidedActionAdapter.ClickListener clickListener)
Sets the click listener for items managed by this adapter.
|
void |
setFocusListener(GuidedActionAdapter.FocusListener focusListener)
Sets the focus listener for items managed by this adapter.
|
bindViewHolder, createViewHolder, getItemId, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
public GuidedActionAdapter(List<GuidedAction> actions, GuidedActionAdapter.ClickListener clickListener, GuidedActionAdapter.FocusListener focusListener, GuidedActionsStylist presenter, boolean isSubAdapter)
actions
- The list of guided actions this adapter will manage.focusListener
- The focus listener for items in this adapter.presenter
- The presenter that will manage the display of items in this adapter.public void setActions(List<GuidedAction> actions)
actions
- The list of actions to be managed.public int getCount()
public GuidedAction getItem(int position)
position
- The position of the desired GuidedAction.public int indexOf(GuidedAction action)
action
- Action to search index.public GuidedActionsStylist getGuidedActionsStylist()
public void setClickListener(GuidedActionAdapter.ClickListener clickListener)
clickListener
- The click listener for this adapter.public void setFocusListener(GuidedActionAdapter.FocusListener focusListener)
focusListener
- The focus listener for this adapter.public List<GuidedAction> getActions()
public int getItemViewType(int position)
position
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. Consider using id resources to uniquely identify item view types.
getItemViewType
in class RecyclerView.Adapter
position
- position to queryposition
. Type codes need not be contiguous.public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
RecyclerView.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(ViewHolder, int, List)
. 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 View.findViewById(int)
calls.
onCreateViewHolder
in class RecyclerView.Adapter
parent
- The ViewGroup into which the new View will be added after it is bound to
an adapter position.viewType
- The view type of the new View.RecyclerView.Adapter.getItemViewType(int)
,
#onBindViewHolder(ViewHolder, int)
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
RecyclerView.ViewHolder.itemView
to reflect the item at the given
position.
Note that unlike 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 RecyclerView.ViewHolder.getAdapterPosition()
which will
have the updated adapter position.
Override #onBindViewHolder(ViewHolder, int, List)
instead if Adapter can
handle efficient partial bind.
onBindViewHolder
in class RecyclerView.Adapter
holder
- The ViewHolder which should be updated to represent the contents of the
item at the given position in the data set.position
- The position of the item within the adapter's data set.public int getItemCount()
getItemCount
in class RecyclerView.Adapter
public GuidedActionsStylist.ViewHolder findSubChildViewHolder(View v)
public void handleCheckedActions(GuidedActionsStylist.ViewHolder avh)
public void performOnActionClick(GuidedActionsStylist.ViewHolder avh)