Class MealPlanController

    • Constructor Detail

      • MealPlanController

        public MealPlanController​(android.app.Activity activity)
        The MealPlanController constructor. Creates a new MealPlanController object.
        Parameters:
        activity - The activity that the controller is being created in.
    • 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.
      • getCurrentMealPlan

        public android.util.Pair<MealPlan,​java.lang.Integer> getCurrentMealPlan()
        Get today's meal plan
        Returns:
        today's meal plan