Project with Dagger2, ViewModels, Junit4 and espresso Testing
This project can help any one looking to set up a new project with clean architecture and test cases.
- MVVM Architecture
- Dagger2
- Retrofit with coroutines support
- LiveData with coroutines
- Mockito for UnitTesting
- Espresso (Working on few more test cases)
api folder has ApiService interface to make api calls using retrofit dagger folder contains the Base Component along with Dagger modules for Network, ViewModels and Activites model class has all the models repository class is responsible for serving data to View Models synonyms folder has the feature where users can search for a word from Urban dictionary.
A little bit about the architecture
Views:
- Views(Activities, Fragments, Adapters etc) hold the Android related code like EditBoxes, Buttons , or any kinda of views.
- ViewModelFactory is injected into views. Which is inturn usefull to get a reference of ViewModel
- Views observe the data on ViewModels and update according to data changes.
ViewModels:
- View models holds the data required by the views.
- Actions like clicks, onChange etc are delegated to ViewModels from Views and correspoding business logics are handled in ViewModels.
- Like asking data from repository layer
- Data in viewModels are updated based on business logic or from the repository which are inturn observed by views
Repository
- Repository servers data to ViewModel.
- Repository can get data either from a local File Storage or a Database or from a Api Call. This is abstracted from viewModels.
- Currently this project is makind use of apiservice class to get data from UrbanDictionay servers.