Package com.xffffff.wellfed.mealplan
Class MealPlanController
- java.lang.Object
-
- com.xffffff.wellfed.mealplan.MealPlanController
-
- All Implemented Interfaces:
DBAdapter.OnDataChangedListener
public class MealPlanController extends java.lang.Object implements DBAdapter.OnDataChangedListener
The MealPlanController class controls the MealPlanActivity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MealPlanController.OnAdapterDataChangedListener
onAdapterDataChangedListener is the interface that is called when the data in the adapter changes.static interface
MealPlanController.OnDataChanged
onDataChanged is the interface that is called when the data in the controller changes.
-
Constructor Summary
Constructors Constructor Description MealPlanController(android.app.Activity activity)
The MealPlanController constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMealPlan(MealPlan mealPlan)
The addMealPlan method for the MealPlanController.void
deleteMealPlan(MealPlan mealPlan, boolean surpressSnackbar)
The deleteMealPlan method for the MealPlanController.MealPlanAdapter
getAdapter()
GetAdapter method for the MealPlanController.android.util.Pair<MealPlan,java.lang.Integer>
getCurrentMealPlan()
Get today's meal planvoid
onDataChanged()
If data is changedRecipe
scaleRecipe(Recipe recipe, java.lang.Long mealPlanServings)
The scaleRecipe method for the MealPlanController.void
setOnAdapterChangedListener(MealPlanController.OnAdapterDataChangedListener listener)
setOnAdapterDataChangedListener sets the OnAdapterDataChangedListener listener.void
setOnDataChanged(MealPlanController.OnDataChanged onDataChanged)
setOnDataChanged sets the OnDataChanged listener.void
startListening(java.lang.String id)
startListening starts listening for changes in the database for the specified meal plan.void
stopListening()
stopListening stops listening for changes in the database.void
updateMealPlan(MealPlan mealPlan)
The updateMealPlan method for the MealPlanController.
-
-
-
Method Detail
-
setOnDataChanged
public void setOnDataChanged(MealPlanController.OnDataChanged onDataChanged)
setOnDataChanged sets the OnDataChanged listener.- Parameters:
onDataChanged
- the OnDataChanged listener
-
setOnAdapterChangedListener
public void setOnAdapterChangedListener(MealPlanController.OnAdapterDataChangedListener listener)
setOnAdapterDataChangedListener sets the OnAdapterDataChangedListener listener.- Parameters:
listener
- the OnAdapterDataChangedListener listener
-
startListening
public void startListening(java.lang.String id)
startListening starts listening for changes in the database for the specified meal plan.- Parameters:
id
- the id of the meal plan
-
stopListening
public void stopListening()
stopListening stops listening for changes in the database.
-
getAdapter
public MealPlanAdapter getAdapter()
GetAdapter method for the MealPlanController. Returns the adapter for the RecyclerView of meal plans.- Returns:
- The adapter for the RecyclerView of meal plans.
-
addMealPlan
public void addMealPlan(MealPlan mealPlan)
The addMealPlan method for the MealPlanController. Adds a new meal plan to the database.- Parameters:
mealPlan
- The meal plan to be added to the database.
-
updateMealPlan
public void updateMealPlan(MealPlan mealPlan)
The updateMealPlan method for the MealPlanController. Updates a meal plan in the database.- Parameters:
mealPlan
- The meal plan to be updated in the database.
-
deleteMealPlan
public void deleteMealPlan(MealPlan mealPlan, boolean surpressSnackbar)
The deleteMealPlan method for the MealPlanController. Deletes a meal plan from the database.- Parameters:
mealPlan
- The meal plan to be deleted from the database.surpressSnackbar
- A boolean indicating whether to surpress the snackbar or not.
-
scaleRecipe
public Recipe scaleRecipe(Recipe recipe, java.lang.Long mealPlanServings)
The scaleRecipe method for the MealPlanController. Scales a recipe to the desired number of servings.- Parameters:
recipe
- The recipe to be scaled.mealPlanServings
- The number of servings to scale the recipe to.- Returns:
- The scaled recipe.
-
onDataChanged
public void onDataChanged()
If data is changed- Specified by:
onDataChanged
in interfaceDBAdapter.OnDataChangedListener
-
getCurrentMealPlan
public android.util.Pair<MealPlan,java.lang.Integer> getCurrentMealPlan()
Get today's meal plan- Returns:
- today's meal plan
-
-