Lecture 6 & HW 6: MVVM, Flows

Textbook: Flows, MVVM Design Pattern

Lecture: Google Slides

Final Feedback Form: [TBD]

Demo: To be posted after the in-class demo

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: P6, DFA

Overview

For this assignment, you are going to create a single-page dog finding application, or DFA for short. Your app will contain information about different dog breeds, and you should allow the user to like and dislike these different breeds. To get this information, you will query the Dog API V2.

Starter code

The starter code for the assignment is linked here. I tried my best to organize the code base in a way that is somewhat close to what you will see in industry, so this assignment should give you practice with traversing code bases that are a bit more robust.

Take some time reading through all the files provided. Especially the comments. I promise you that doing this up front will save you a lot of time in the long run.

Requirements

The final result should look something like this. The specific requirements areas are as follows:

  1. Scrolling to the bottom shows a loading spinner and then loads more dog breeds from the API. Note that the API is very fast, so when testing this functionality you may want to add a delay manually so you can see the loading spinner.

  2. Use flows to allow the user to favorite dog breeds, and show the updates live. Using combine will make this easier!

  3. Favoriting a dog breed must move it into the favorites category from the all breeds category, as in the dog breed may not be in the all breeds category once it is a favorite.

  4. In the infinite list, each dog breed card must display the breed name, male and female weights, whether it is hypoallergenic, and the description. Refer to the screenshot for an example.

  5. You must use the MVVM design pattern best practices as we went over in class. This includes implementing DogRepository (model), MainScreenViewModel (view model), and MainScreen (view). Your ViewModel should expose a single viewState flow to the view (which has been defined for you).

How to get started

Again, the best way to start the assignment is by reading through and understanding the structure of the starter code. After that, an easier first task is specifying the UI and making some previewable composables to plan out how you'll display your information. From there, you can start implementing some of the code. You'll probably want to start by specifying DogBreedApi, and then work your way through MVVM, starting with the model and working downwards.

Last updated