Class RecipeAdapter

  • All Implemented Interfaces:
    com.google.firebase.firestore.EventListener<com.google.firebase.firestore.QuerySnapshot>

    public class RecipeAdapter
    extends DBAdapter<RecipeAdapter.ViewHolder>
    Adapter for the recipes in the RecipeBookFragment Binds the view for each recipe to the data
    • Constructor Detail

      • RecipeAdapter

        public RecipeAdapter​(RecipeDB db)
        Creates a new RecipeAdapter given the RecipeDB.
        Parameters:
        db - the Recipe database that the adapter is connected to
    • Method Detail

      • setRecipeLauncher

        public void setRecipeLauncher​(RecipeAdapter.RecipeLauncher recipeLauncher)
        Sets the RecipeLauncher for the recipe adapter
        Parameters:
        recipeLauncher - the recipe launcher
      • onCreateViewHolder

        @NonNull
        public RecipeAdapter.ViewHolder onCreateViewHolder​(@NonNull
                                                           android.view.ViewGroup parent,
                                                           int viewType)
        Inflate the layout of a single View into the parent ViewGroup
        Specified by:
        onCreateViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<RecipeAdapter.ViewHolder>
        Parameters:
        parent - the parent ViewGroup to inflate the layout in
        viewType - an identifier for the view type
        Returns:
        the new ViewHolder for a Recipe created
      • onBindViewHolder

        public void onBindViewHolder​(@NonNull
                                     RecipeAdapter.ViewHolder holder,
                                     int position)
        Bind the data with the views in the RecyclerView
        Specified by:
        onBindViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<RecipeAdapter.ViewHolder>
        Parameters:
        holder - the ViewHolder which holds Views to be bound to the recipe
        position - the position of the View in the ViewHolder to bind the data to