The following is a sample android project on how to use the Model View ViewModel (MVVM) architecture with Retrofit which is a type-safe HTTP client for Android and Java and JSONPlaceholder which is a fake online REST API for testing and prototyping.
The MVVM architecture is the recommended architecture for developing android application. MVVM provides the following benefits:
- Separation of concerns which enables developers to write maintainable code.
- Survive configuration changes (such as screen rotations) which improves user experience
The network request returns a list of users which is displayed in a RecyclerView as illustrate in the demo bellow.
- ViewModel
- LiveData
- view-binding
- Retrofit
- JSONPlaceholder
- RecyclerView
- CardView
- Monitor connectivity status
- Lombok added for getters and setter inside user model class