Package com.xffffff.wellfed.recipe
Class RecipeAdapter
- java.lang.Object
-
- androidx.recyclerview.widget.RecyclerView.Adapter<VH>
-
- com.xffffff.wellfed.common.DBAdapter<RecipeAdapter.ViewHolder>
-
- com.xffffff.wellfed.recipe.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 theRecipeBookFragment
Binds the view for each recipe to the data
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RecipeAdapter.RecipeLauncher
Interface for launching a new recipe activity.static class
RecipeAdapter.ViewHolder
Holds the views for the recipes-
Nested classes/interfaces inherited from class com.xffffff.wellfed.common.DBAdapter
DBAdapter.OnDataChangedListener
-
-
Constructor Summary
Constructors Constructor Description RecipeAdapter(RecipeDB db)
Creates a new RecipeAdapter given the RecipeDB.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onBindViewHolder(RecipeAdapter.ViewHolder holder, int position)
Bind the data with the views in the RecyclerViewRecipeAdapter.ViewHolder
onCreateViewHolder(android.view.ViewGroup parent, int viewType)
Inflate the layout of a single View into the parent ViewGroupvoid
setRecipeLauncher(RecipeAdapter.RecipeLauncher recipeLauncher)
Sets the RecipeLauncher for the recipe adapter-
Methods inherited from class com.xffffff.wellfed.common.DBAdapter
getItemCount, getSnapshot, getSnapshots, onDataChanged, 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
-
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 classandroidx.recyclerview.widget.RecyclerView.Adapter<RecipeAdapter.ViewHolder>
- Parameters:
parent
- the parent ViewGroup to inflate the layout inviewType
- 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 classandroidx.recyclerview.widget.RecyclerView.Adapter<RecipeAdapter.ViewHolder>
- Parameters:
holder
- the ViewHolder which holds Views to be bound to the recipeposition
- the position of the View in the ViewHolder to bind the data to
-
-