Android project that uses the MVVM pattern and Clean architecture to show a list of movies and their detail.
This app uses Android Architecture components with Koin.
The architecture is divided into 3 layers:
I use Repository implementations to control the flow of data access. In those repositories where there is more than one data source, the abstract class PrefetchLocalData guides the search according to the precept of Single source of truth.
This layer includes those models that are part of the project core (and are independent of the data layer) and the repository interfaces. Also belong the Interactors, which use repositories and models to accomplish the use case.
This layer consists mainly of Activity-ViewModel pairs.
The ViewModel is the fundamental piece of the MVVM pattern. It exposes LiveData objects, which are lifecycle-aware, and thanks to this it can protect the state of the information in situations such as changing the orientation of the screen.
On the other hand, the management of asynchrony is done through an instance of InteractorExecutor, which is responsible for launching the execution of Interactors.
The Activity acts as a simple Observer of the data exposed by the ViewModel.
In this project I have focused mainly on covering with unit tests the classes that contain most of the logic of the app: ViewModels and Interactors.