MVP-2: Presenters should be Android- and framework-independent.


Description

To abstract Presenter components from the implementation details, Presenters should ideally avoid dependencies to the Android framework. This also entails not creating a lifecycle in Presenters, as it may hinder their maintainability and evolvability. In order to access app resources and preferences, View and Model components can be used instead, respectively. Additionally, by developing Presenters as only dependent on Java, the testability of Presenters drastically improves, as now non-instrumented unit-test cases can be written for such components.

Example

We created a simple application which retrieves employees from this url: http://dummy.restapiexample.com/api/v1/

The event diagram of the Boss Application:

Login Injection

Each component can easily be tested. Since the MainPresenter has no actual reference to the MainActivity the MainPresenter is Android-independent making the presenter testable without an emulator.

Check out the Github page to view the complete repository.