public class RecipeRepository extends Object
MainViewModel
and interacts with the JsoupMachine
.Modifier and Type | Method and Description |
---|---|
Completable |
connect(String url)
This is the first step is processing a website.
|
Single<Integer> |
delete(Recipe recipe) |
Single<List<String>> |
generateStrings()
This method sends the retrieved document to the
JsoupMachine to extract String elements. |
LiveData<List<Recipe>> |
getAll() |
static RecipeRepository |
getInstance() |
Single<Recipe> |
loadDetails(long id) |
Single<AssemblyRecipe> |
process(String ingredient,
String instruction)
This method passes the user inputs to the
JsoupMachine for processing. |
Single<Recipe> |
saveNew(Recipe recipe)
This save method adds a new Recipe to the database and applies its generated id to the recipeId
field in all of its Steps and Ingredients.
|
static void |
setContext(Application context) |
Single<Integer> |
update(Recipe recipe) |
public static void setContext(Application context)
context
- ChoppitApplication.public static RecipeRepository getInstance()
public Single<Recipe> saveNew(Recipe recipe)
recipe
- is received from the EditingFragmentpublic Single<Integer> update(Recipe recipe)
recipe
- is received from the EditingFragment.public LiveData<List<Recipe>> getAll()
Recipe
s for display in the CookbookFragment
.public Single<Recipe> loadDetails(long id)
id
- database search parameter received from either the RecipeFragment or EditingFragmentpublic Single<Integer> delete(Recipe recipe)
recipe
- received by the DeleteDialog.public Completable connect(String url)
doc
if the connection is successful.url
- is received from the user.public Single<List<String>> generateStrings()
JsoupMachine
to extract String elements.public Single<AssemblyRecipe> process(String ingredient, String instruction)
JsoupMachine
for processing. The resulting
data is passed back up to the MainViewModel
and eventually displayed in the EditingFragment
.ingredient
- input by the user on the SelectionFragment
instruction
- input by the user on the SelectionFragment
Step
objects with attached Ingredient
s.