public class LibraryAdapter extends RecyclerView.Adapter<LibraryAdapter.Holder>
List
<
MediaBrowserCompat.MediaItem
>
adapter for a RecyclerView
that displays each item's title and icon as a grid card.Modifier and Type | Class and Description |
---|---|
class |
LibraryAdapter.Holder
Represents an entry in a
LibraryAdapter . |
Constructor and Description |
---|
LibraryAdapter(List<MediaBrowserCompat.MediaItem> dataset,
com.moppyandroid.main.LibraryAdapter.ClickListener clickListener)
|
Modifier and Type | Method and Description |
---|---|
int |
getItemCount()
Gets the size of the data set.
|
void |
onBindViewHolder(LibraryAdapter.Holder holder,
int position)
Method triggered when a
LibraryAdapter.Holder is bound to the RecyclerView . |
LibraryAdapter.Holder |
onCreateViewHolder(ViewGroup parent,
int viewType)
Method triggered when a
RecyclerView.ViewHolder is created. |
bindViewHolder, createViewHolder, getItemId, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
public LibraryAdapter(List<MediaBrowserCompat.MediaItem> dataset, com.moppyandroid.main.LibraryAdapter.ClickListener clickListener)
dataset
- the List
to showpublic LibraryAdapter.Holder onCreateViewHolder(ViewGroup parent, int viewType)
RecyclerView.ViewHolder
is created.onCreateViewHolder
in class RecyclerView.Adapter<LibraryAdapter.Holder>
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(LibraryAdapter.Holder holder, int position)
LibraryAdapter.Holder
is bound to the RecyclerView
.onBindViewHolder
in class RecyclerView.Adapter<LibraryAdapter.Holder>
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<LibraryAdapter.Holder>