Using Android MVP Library

Android MVP is a Library that helps you to easily build Android applications that require some complexity and thus if you do not use any architecture pattern it can easily get unmaintainable and messy.

If you are not familiarized with MVP and its variants, I would strongly recommend that you read this article I wrote some time ago.

Also, I would strongly recommend using this plugin to make the boilerplate of creating all classes and communications less painful. Please read this article I wrote to get started with the plugin and learn how to use it.

Artifacts (Events + Coroutines)

//Events oriented MVP Lib
implementation "com.github.marcherdiego.mvp:events:LATEST_VERSION"
//Coroutines module to work extend Models
implementation "com.github.marcherdiego.mvp:coroutines:LATEST_VERSION"

Check the latest versions of each library here.


Your activity should look like this. Notice that there is no need to register or unregister to the bus since all this life cycle states are handled by the BaseActivity.

Let’s take a look at the ExampleFeatureView class which is in charge of holding the widgets and forward any interaction to the Presenter(through the bus, obviously).

Now let’s see how the Presenter gets noticed of this event and how it tells the Model that some task should be done.

Now let’s take a look at the Model class which is in charge of any heavy work, business logic, etc. For simplicity, we are going to use an AsyncTask to show that there is some background task being executed, but of course, you can use any library such as Retrofit, Robospice, Volley, etc.

Now let’s add the handlers for the events SomeBackgroundTaskFinishedSuccessfullyEvent and SomeBackgroundTaskFailedEvent

That’s it, you have now a fully testable Presenter and Model, and you can forget the View since it’s not doing any logic, only holding widgets that we assume that are well tested :).

That’s it!

Android Engineer @UJET