@@ -0,0 +1,1996 @@
+package com.example.profbola.bakingtime.services;%0A%0Aimport android.content.Context;%0Aimport android.support.annotation.NonNull;%0A%0Aimport com.example.profbola.bakingtime.models.Ingredient;%0Aimport com.example.profbola.bakingtime.models.Recipe;%0Aimport com.example.profbola.bakingtime.models.Step;%0Aimport com.example.profbola.bakingtime.provider.RecipeContract;%0Aimport com.example.profbola.bakingtime.utils.RecipeNetworkUtil;%0Aimport com.example.profbola.bakingtime.utils.RecipeParser;%0A%0Aimport org.json.JSONArray;%0A%0Aimport java.util.List;%0A%0Aimport static com.example.profbola.bakingtime.provider.RecipeContract.RecipeEntry.CONTENT_URI;%0A%0A/**%0A * Created by prof.BOLA on 7/5/2017.%0A */%0A%0Apublic class RecipeTasks %7B%0A%0A    synchronized static void writeRecipes(@NonNull Context context) %7B%0A%0A        JSONArray jsonArray = RecipeNetworkUtil.getRecipeFromApi();%0A        List%3CRecipe%3E recipeParser = RecipeParser.parse(jsonArray);%0A%0A        for (Recipe recipe: recipeParser) %7B%0A            insertRecipe(context, recipe);%0A            insertIngredients(context, recipe);%0A            insertSteps(context, recipe);%0A        %7D%0A%0A    %7D%0A%0A    private static void insertSteps(Context context, Recipe recipe) %7B%0A        int id = recipe.id;%0A        for (Step step: recipe.steps) %7B%0A            context.getContentResolver().insert(%0A                    RecipeContract.StepEntry.CONTENT_URI(id),%0A                    step.toContentValues(id)%0A            );%0A        %7D%0A    %7D%0A%0A    private static void insertIngredients(Context context, Recipe recipe) %7B%0A        int id = recipe.id;%0A        for (Ingredient ingredient: recipe.ingredients) %7B%0A            context.getContentResolver().insert(%0A                    RecipeContract.IngredientEntry.CONTENT_URI(id),%0A                    ingredient.toContentValues(id)%0A            );%0A        %7D%0A    %7D%0A%0A    private static void insertRecipe(Context context, Recipe recipe) %7B%0A        context.getContentResolver().insert(%0A                CONTENT_URI,%0A                recipe.toContentValues()%0A        );%0A    %7D%0A%7D%0A

Add Recipe DB writer task