In this assignment you will develop “RecipePuppy recipe finder” app. The App displays recipes from Recipe Puppy (http://www.recipepuppy.com/). This allows you to search the recipes of the dish you are interested in, with proper ingredients. In this assignment, you will learn how to parse JSON. The base URL of the API is: http://www.recipepuppy.com/api/?i=<INGREDIENTS LIST, COMMA SEPARATED>&q=. An example URL is: http:// www.recipepuppy.com/api/?i=onions,garlic&q=omelet . You can load the URL in codebeautify.org/jsonviewer for better understanding of JSON you receive. In this assignment we will build two activities. The first activity is to search, and the second activity is to display the results of the recipe search. Search Activity (30 Points) You need to implement the following:
- An EditText to put the dish name.
- A scrollable add ingredients panel which can add up to 5 ingredients in total. Page 2 of 4 (a)Search Screen (b) Added a list of ingredients (c) Loading recipes (d) Display recipes Figure 1, App Wireframe Recipe Puppy Search Dish Add Ingredients Recipes Title: Monterey Turkey Omelet Ingredients: butter, eggs, garlic, green pepper, monterey jack cheese, icons, turkey, water URL: http://allrecipes.com/recipe/116899/ monterey-turkey-omelet/ Finish Recipes Loading... Recipe Puppy Search Dish Add Ingredients Omelet Onions Garlic
- The panel to add ingredients should be implemented using Dynamic Layout. It should follow the same pattern you did in the Homework, see figure 1 (b).
- It should display an empty EditText, and a floating action Add button. Once, you add one ingredient, the floating action button should be changed from Add to Remove button. Follow figure 1(b).
- Then you need to create the URL as: http://www.recipepuppy.com/api/? i=<INGREDIENTS LIST, COMMA SEPARATED>&q=.
- There should be a Search button. Clicking on that button should take you to the Display recipes activity where it displays a list of recipes. Recipes Activity (60 Points)
- Use an AsyncTask or Thread pool to communicate with the RecipePuppy api and to parse the result. Do not use the main thread to parse them.
- In our example, we wanted to search for a Omelet recipe having two key ingredients: Onions, and Garlic.
- In received JSON, you will find that there are two levels of the hierarchy. Inside “array”, you will find “results”. You need to parse all the items in results.
- Use AsyncTask or Thread pool to retrieve and parse it.
- You need to implement a ProgressBar to display the progress while it is parsing, see figure 1(c).
- Finally display your result. Please follow the instructions:
- You have four things to display:
- Title (“title” in JSON)
- Recipe image (“thumbnail” in JSON)
- Ingredients (“ingredients” in JSON)
- URL (“href” in JSON)
- You need to use a separate AsyncTask when you load the image. Alternatively, you can use Picasso library to load the image. (http://square.github.io/picasso/).
- The URL should be clickable, use implicit intents to open it in browsers.
- Next you need to implement a navigation pane. It will have five buttons.
- The leftmost button is the indicator of first recipe.
- The second button indicates the previous recipe.
- The Finish button is to close the app.
- The fourth button indicates the next recipe.
- The rightmost button indicates the last recipe.
- Corner Cases:
- Last recipe: clicking on the next button should not take you anywhere. Toast to confirm that it is the last recipe. Page 3 of 4
- First recipe: clicking on the previous button should toast to display that it is the first recipe.
- If no recipe is found, return to the main activity and toast to report that there were no recipes found.
- Clicking on Finish button should Finish the second activity and return you to the main activity.