public class StepRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
EditingFragment
or
RecipeFragment
.Modifier and Type | Class and Description |
---|---|
class |
StepRecyclerAdapter.EditStepViewHolder
The ViewHolder class attaches Step fields to UI components.
|
class |
StepRecyclerAdapter.RecipeStepViewHolder
The ViewHolder class attaches Ingredient fields to UI components.
|
Constructor and Description |
---|
StepRecyclerAdapter(Context context,
Recipe recipe,
Fragment uiFragment)
Handles Data Binding for a list of Steps passed by the active Fragment while displaying a
Recipe.
|
Modifier and Type | Method and Description |
---|---|
void |
addStep()
Allows the user to add a new Step
|
void |
deleteStep(int position)
Allows the user to delete a single Step.
|
int |
getItemCount() |
void |
onBindViewHolder(RecyclerView.ViewHolder viewHolder,
int position)
Attaches each Step to a ViewHolder.
|
RecyclerView.ViewHolder |
onCreateViewHolder(ViewGroup parent,
int viewType) |
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 StepRecyclerAdapter(Context context, Recipe recipe, Fragment uiFragment)
context
- the Context where the adapter operatesrecipe
- is received from the active Fragment.uiFragment
- is the active Fragment when this Adapter is being used.@NonNull public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
onCreateViewHolder
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
parent
- where the new ViewHolder will be added.viewType
- is not used in this override.public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position)
onBindViewHolder
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
viewHolder
- generated by onCreateViewHolder(ViewGroup, int)
position
- the position of the Step being added.public int getItemCount()
getItemCount
in class RecyclerView.Adapter<RecyclerView.ViewHolder>
public void addStep()
public void deleteStep(int position)
position
- the adapter position of the Step to be deleted.