Recipe browser app with fragments
Create a recipe browser app similar to the one in Lab3, the rating part from the lab is not needed for this homework. The app allows listing of recipes and opening the detailed contents of individual recipes.
In portrait mode, the app should:
- Initially, display a list of recipe titles in one fragment (filling the entire screen) (1 pt)
- Clicking on a recipe should replace the "recipe list" fragment with a "recipe details" fragment (1 pt)
- The details fragment should display the title and full content of a recipe. Use Fragment argument bundles to pass data to the fragment here.
In landscape mode, the app should:
- show 2 fragments side-by-side (1 pt)
- The left fragment should be narrower, and show the same "recipe list"
- The right fragment should initially be empty (not displaying any recipe contents)
- Clicking on a recipe, should display the recipe title + contents in the same "recipe details" fragment as above, except this fragment is now visible simultaneously with the recipe list fragment (1 pt)
- Clicking on a recipe should fully replace any existing "recipe details" fragment with a new one ( using fragment transactions).
- Hitting the Back button when in Recipe Details view should bring the user back to the Recipe List in portrait mode or the previous selected recipe in landscape mode (use addToBackStack( ) with your fragment transaction). (0.5 pts)
- The recipe titles and contents should be loaded from a .json file, you can re-use .json solution from Lab 3.
- Similar to lab3, each view component (e.g. Details Fragment) should load the necessary data from the .json file by itself. Use Recipe ID-s to keep the data passed to Fragments via arguments light. (0.5 pts)
Additional requirements:
- You should have exactly 2 Fragment Kotlin classes, (RecipeDetailsFragment, RecipeListFragment) and 1 Activity class (MainActivity)
- You should have 4 layout XML files:
- 2 for your main activity (portrait and landscape modes).
- 1 for the recipe list fragment.
- 1 for the recipe details fragment.
Tips: How to make MainActivity display different fragments based on device orientation? There are different options, e.g.:
- You check the value of use getResources().getConfiguration().orientation
- You could check whether or not some View object is currently present in the Activity with findViewById (if you your Activity layout for portrait mode uses different ID-s than for landsacpe mode, you can check which ones are present to determine the orientation)
Feel free to be creative with the design of the app. If you make some additional assumptions, it's recommended to document them.