In this tutorial we are demonstrating how to build an android MVP structure with Dagger2 dependency injection. I've aimed to build a trivial small app to avoid the complexity, and to present the main point of the project in clear way.
in this app I will avoid descripting any third part library to keep focus on the MVP structure and dagger2.
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.
Model–view–presenter (MVP) is a derivation of the model–view–controller (MVC) architectural pattern, and is used mostly 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.
- Model: It is responsible for handling the data part of the application.
- View: It is responsible for laying out the views with specific data on the screen.
- Presenter: It is a bridge that connects a Model and a View. It also acts as an instructor to the View.
- A View’s sole responsibility is to draw UI as instructed by the Presenter. It is a dumb part of the application.
- View delegates all the user interactions to its Presenter.
- The View never communicates with Model directly.
- The Presenter is responsible for delegating View’s requirements to Model and instructing View with actions for specific events.
- Model is responsible for fetching the data from server, database and file system.
- calligraphy custom fonts: https://medium.com/@geekonjava/how-to-add-custom-font-in-android-using-calligraphy-library-5a086b28b569
- Picasso image loader: http://square.github.io/picasso/
- ButterKnife: http://jakewharton.github.io/butterknife/
- Dagger2 dependency injection: https://medium.com/@iammert/new-android-injector-with-dagger-2-part-1-8baa60152abe
Check out amjadomari awesome open source projects here
Just make pull request. You are in!