MVP-10: Inject dependencies to Presenters into the Views when instantiating the Presenters, as this reduces coupling issues and null checks.


Description

Injecting presenters using Dagger reduces null checks and setPresenter() methods. Whenever an activity is used, Dagger couples the view with the Presenter. Which ultimately results into clearer code.

Example

We created a simple MVP login Application.

The ViewUserModule provides the ViewUserComponent with the ViewUserPresenter.

This ViewUserPresenter gets initialized with the viewUsersView. Which is added when the module is instantiated.

Which happens in the viewUsersActivity. So whenever a new Presenter is created, the Presenter always has a relationship with a view. So this is never null.

Check out the Github page to view the complete repository.