Class RecipeController


  • public class RecipeController
    extends java.lang.Object
    Handles the business logic for the Recipes
    • Constructor Summary

      Constructors 
      Constructor Description
      RecipeController​(androidx.fragment.app.FragmentActivity activity)
      Constructor that initializes the db connection and the adapter for the recipes
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRecipe​(Recipe recipe)
      Adds the recipe to db and notifies the adapter
      void deleteRecipe​(Recipe recipe)
      Requests the database to delete a Recipe and handles the result
      void editRecipe​(Recipe recipe)
      Requests the database to edit a Recipe and handles the result
      RecipeAdapter getRecipeAdapter()
      Gets the RecipeAdapter that connects the list of Recipes to the DB
      RecipeDB getRecipeDB()  
      void search​(java.lang.String field)  
      void sort​(java.lang.String field)
      Gets the sorted query of recipes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RecipeController

        public RecipeController​(androidx.fragment.app.FragmentActivity activity)
        Constructor that initializes the db connection and the adapter for the recipes
        Parameters:
        activity - the activity that the controller is controlling
    • Method Detail

      • getRecipeDB

        public RecipeDB getRecipeDB()
        Returns:
        recipeDB connection
      • editRecipe

        public void editRecipe​(Recipe recipe)
        Requests the database to edit a Recipe and handles the result
        Parameters:
        recipe - the recipe to edit in the database
      • deleteRecipe

        public void deleteRecipe​(Recipe recipe)
        Requests the database to delete a Recipe and handles the result
        Parameters:
        recipe - of the recipe to delete
      • addRecipe

        public void addRecipe​(Recipe recipe)
        Adds the recipe to db and notifies the adapter
        Parameters:
        recipe - the recipe to add
      • sort

        public void sort​(java.lang.String field)
        Gets the sorted query of recipes.
        Parameters:
        field - the field to sort by
      • getRecipeAdapter

        public RecipeAdapter getRecipeAdapter()
        Gets the RecipeAdapter that connects the list of Recipes to the DB
        Returns:
        the RecipeAdapter
      • search

        public void search​(java.lang.String field)