public class RecyclerViewAdapter extends androidx.recyclerview.widget.RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>
Modifier and Type | Class and Description |
---|---|
class |
RecyclerViewAdapter.ViewHolder
Model ViewHolder which holds image and recipe name
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
CLICKED_ITEM |
private android.content.Context |
mContext |
private java.util.List<RecipeWithIngredients> |
recipeWithIngredients |
private static java.lang.String |
TAG |
Constructor and Description |
---|
RecyclerViewAdapter(java.util.List<RecipeWithIngredients> recipeWithIngredients,
android.content.Context Context)
Constructor RecyclerViewAdapter with parameters
|
Modifier and Type | Method and Description |
---|---|
int |
getItemCount()
This function tell how many items are in the list
|
void |
onBindViewHolder(RecyclerViewAdapter.ViewHolder holder,
int position)
This method is called to connect a ViewHolder with data.
|
RecyclerViewAdapter.ViewHolder |
onCreateViewHolder(android.view.ViewGroup parent,
int viewType)
This method is called whenever a new ViewHolder is created.
|
bindViewHolder, createViewHolder, findRelativeAdapterPositionIn, getItemId, getItemViewType, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver
private static final java.lang.String TAG
private static final java.lang.String CLICKED_ITEM
private java.util.List<RecipeWithIngredients> recipeWithIngredients
private android.content.Context mContext
public RecyclerViewAdapter(java.util.List<RecipeWithIngredients> recipeWithIngredients, android.content.Context Context)
recipeWithIngredients
- ListContext
- context@NonNull public RecyclerViewAdapter.ViewHolder onCreateViewHolder(@NonNull android.view.ViewGroup parent, int viewType)
onCreateViewHolder
in class androidx.recyclerview.widget.RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>
parent
- ViewGroupviewType
- type of viewpublic void onBindViewHolder(@NonNull RecyclerViewAdapter.ViewHolder holder, int position)
onBindViewHolder
in class androidx.recyclerview.widget.RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>
holder
- ViewHolderposition
- position as integerpublic int getItemCount()
getItemCount
in class androidx.recyclerview.widget.RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>