This project demonstrates Model-View-Presenter pattern + Dagger + Retrofit usage in android.
Model–view–presenter (MVP) is a derivation of the model–view–controller (MVC) architectural pattern which mostly used for building user interfaces. In MVP, the presenter assumes the functionality of the “middle-man”. In MVP, all presentation logic is pushed to the presenter. MVP advocates separating business and persistence logic out of the Activity and Fragment.
Dagger 2 is dependency injection framework. It is based on the Java Specification Request (JSR) 330. It uses code generation and is based on annotations. The generated code is very relatively easy to read and debug.
Retrofit is type-safe REST client for Android and Java which aims to make it easier to consume RESTful web services.
Following notable libraries have been used in this project
- Retrofit 2 for API interaction
- Dagger 2 for dependency injection.
I have used Dagger SubComponents
to pass dependencies down in dependency graph.
Some nice articles for learning Dagger 2
:
- Dependency Injection with Dagger 2- CodePath
- Dependency injection with Dagger 2 - the API
- Introduction to Dagger 2, Using Dependency Injection in Android: Part 2
- An Introduction to Dagger 2 (Android DI) – Part 1
Happy Coding!!