Package com.xffffff.wellfed.mealplan
Class MealPlanAdapter
- java.lang.Object
-
- androidx.recyclerview.widget.RecyclerView.Adapter<VH>
-
- com.xffffff.wellfed.common.DBAdapter<MealPlanViewHolder>
-
- com.xffffff.wellfed.mealplan.MealPlanAdapter
-
- All Implemented Interfaces:
com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>
public class MealPlanAdapter extends DBAdapter<MealPlanViewHolder>
The MealPlanAdapter class binds ArrayList to RecyclerView.Citation: Create dynamic lists with RecyclerView. Android Developers. (n.d.). Retrieved September 26, 2022, from https://developer.android.com/develop/ui/views/layout/recyclerview
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.xffffff.wellfed.common.DBAdapter
DBAdapter.OnDataChangedListener
-
-
Constructor Summary
Constructors Constructor Description MealPlanAdapter(MealPlanDB db)
The constructor for the MealPlanAdapter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ArrayList<MealPlan>
getMealPlans()
getMealPlans returns the meal plans in the adaptervoid
onBindViewHolder(MealPlanViewHolder holder, int position)
The onBindViewHolder method binds a MealPlan object and a MealPlanViewHolder, taking the data in the MealPlan object and mapping it into a human readable format to be presented in the RecyclerView.MealPlanViewHolder
onCreateViewHolder(android.view.ViewGroup parent, int viewType)
The onCreateViewHolder method returns a new MealPlanViewHolder object using the viewholder_MealPlan.xml view.protected void
onDataChanged(com.google.firebase.firestore.DocumentChange change)
onDataChanged is called when the data in the adapter changesvoid
setOnItemClickListener(OnItemClickListener<MealPlan> listener)
Sets the listener for an item click in the Recyclerview-
Methods inherited from class com.xffffff.wellfed.common.DBAdapter
getItemCount, getSnapshot, getSnapshots, onEvent, setOnDataChangedListener, setQuery, startListening, stopListening
-
Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter
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
-
-
-
-
Constructor Detail
-
MealPlanAdapter
public MealPlanAdapter(MealPlanDB db)
The constructor for the MealPlanAdapter- Parameters:
db
- the MealPlanDB
-
-
Method Detail
-
getMealPlans
public java.util.ArrayList<MealPlan> getMealPlans()
getMealPlans returns the meal plans in the adapter- Returns:
- the meal plans in the adapter
-
onDataChanged
protected void onDataChanged(com.google.firebase.firestore.DocumentChange change)
onDataChanged is called when the data in the adapter changes- Overrides:
onDataChanged
in classDBAdapter<MealPlanViewHolder>
- Parameters:
change
- the document change
-
setOnItemClickListener
public void setOnItemClickListener(OnItemClickListener<MealPlan> listener)
Sets the listener for an item click in the Recyclerview- Parameters:
listener
- the listener to set
-
onCreateViewHolder
@NonNull public MealPlanViewHolder onCreateViewHolder(@NonNull android.view.ViewGroup parent, int viewType)
The onCreateViewHolder method returns a new MealPlanViewHolder object using the viewholder_MealPlan.xml view.- Specified by:
onCreateViewHolder
in classandroidx.recyclerview.widget.RecyclerView.Adapter<MealPlanViewHolder>
-
onBindViewHolder
public void onBindViewHolder(@NonNull MealPlanViewHolder holder, int position)
The onBindViewHolder method binds a MealPlan object and a MealPlanViewHolder, taking the data in the MealPlan object and mapping it into a human readable format to be presented in the RecyclerView.- Specified by:
onBindViewHolder
in classandroidx.recyclerview.widget.RecyclerView.Adapter<MealPlanViewHolder>
- Parameters:
holder
- The MealPlanViewHolder object.position
- The position of the MealPlan object in the ArrayList.
-
-