Class 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

    • 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 adapter
      void 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 changes
      void setOnItemClickListener​(OnItemClickListener<MealPlan> listener)
      Sets the listener for an item click in the Recyclerview
      • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 class DBAdapter<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 class androidx.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 class androidx.recyclerview.widget.RecyclerView.Adapter<MealPlanViewHolder>
        Parameters:
        holder - The MealPlanViewHolder object.
        position - The position of the MealPlan object in the ArrayList.