Lecture 6 & HW 6: Networking, Data, and Persistent Storage

Final Feedback Form: [TBD]

Quick Note:

Y'all are awesome! Thank you for all of your hard work so far; we have a small enough class for me to know that each of you (yes, ALL) are very talented and bright Android Developers. I wish you all success and happiness ☺.

Homework Instructions:


Note: Nothing in this assignment depends on HW5.

Your goal for this week's assignment is to build off your HW5 social media app with a new feature. There will be a new "For You" tab, which will fetch data from the internet to display posts.

You will create a new screen accessible by Bottom Navigation. It will have a similar structure to the list of posts, but instead of pre-defined images, you are going to use this API to retrieve randomly generated images:

Notes on the API: We suggest you use the endpoint https://dog.ceo/api/breeds/image/random/3 to retrieve a list of images. You can change the number at the end to fetch any number of images at the same time (i.e. fetch the same number of images as the size of your post list).


  1. Use what you had previously in HW5.

  2. Create a ForYouScreen with a LazyList of posts, similar to what you did in HW5 with the MainScreen. If you created a Composable component to represent an individual post, you should reuse it for this screen! You do not need to have functionality to edit the posts on this screen, just displaying them without clicking is fine.

  3. Create a ForYouViewModel that uses OkHTTP and Moshi to call the endpoint and store it into a variable in your ViewModel. Create models annotated with Moshi to reflect the structure of the API endpoint. Your ForYouScreen should be defining its data based on the ForYouViewModel.


  1. In the LazyList in your ForYouScreen, you may be iterating through your posts via an integer index. This is a good way to associate your list of retrieved images with your list of posts, assuming both lists are the same size.

  2. Before the images are retrieved (as it takes time for an HTTP request to complete), don't display anything.

Last updated