A sample android app that shows how to use ViewModels and Room together with RxJava & Pure Depdency Injection, in Java by Clean Architecture.
Implemented by Clean Architecture
- Presentation (Activity/Fragment and ViewModel)
- Domain (Interactor/Usecases, Repository Interface and Model classes)
- Data (Local/remote datastore and Respository implementation)
Dependecy between compoents
Activity/Fragment --> ViewModel --> Usecase(Interactor) --> Repository --> LocalDataStore(Room DB)
Communication between layers
- UI calls method from ViewModel.
- ViewModel executes Use case.
- Use case combines data from Album and Photo Repositories.
- Each Repository returns data from a Data Source (Cached or Remote).
- Information flows back to the UI where we display the list of posts.
- Navigator
- ResourceManger
Scenario
At a glance:
- Use can either Register or Login if already registered
- Once authenticated, show list of todos with option to add new todo
- Once tap on each item, show edit/delete todo screen
References
Room Unit testin - https://proandroiddev.com/testing-the-un-testable-and-beyond-with-android-architecture-components-part-1-testing-room-4d97dec0f451