During the last couple of months I have been reading about how to architect and design Android applications. I have found a plethora of solutions and blog posts regarding this topic. Nevertheless, in most cases, I have found the proposed solutions to be either to complicated, involving to much boilerpart code, depending on external libraries, or not complete enough. The previous remark is obviously subjective, the solutions were great and I have to bow and thank all the wonderful people who took their time to share their knowledge and experience. So, thank you all you wonderful people!
I did however learn a great deal about how to architect and design Android applications, using a clean architecture for the application as a whole, and an MVP design for the presentation layer of the application.
So my problem was how to implement a simple, decoupled, testable, asynchronous MVP design, without using any 3rd party libraries, that can also handle screen orientation and satisfy my own needs for my own projects.
The biggest issues I had, were how to do background processing of long running tasks, how to communicate the results of these tasks to the user interface, and how to gracefully handle screen orientation.
In order to spare myself some time, I shall only post the links to the resources that you need to get started with this solution. You can find more details in the GitHub descriptions of the repositories and there is also a YouTube video about it.
Also please consider that this proposed solutions is just another implementation of the MVP pattern in Android, and in no circumstances is this the only and best solutions. Take everything with a grain of salt, hear more opinions on this topic, and find out what works best for you.
You can get running demo application here: AndroidAsynchronousMVP on Google Play.
You can get the code for the application here: AndroidAsynchronousMVP on GitHub.
You can also get only a boilerpart version of the code, meaning just the basics you need to use this solution in your own applications: AndroidAsynchronousMVPBoilerpart.
And here is the video with more details about this solution and the boilerpart code:
If you checkout the git repository, you will notice that the project has multiple branches. This article is based on the master branch, so use this as a starting point.
Also look at the other branches to see different implementations of the same concept.
Some solutions are more loosely coupled, meaning that the presenter knows about the model and not vice-versa. While some solutions are more tightly coupled meaning that the model also knows about the presenter.
Some solutions implement the asynchronous behaviors in the view, others in the presenters.
Nevertheless all solutions achieve the same goal.
There are multiple ways to achieve the same goal.
Testing is directly affected by the choice of implementation.
The design becomes more clear is the asynchronous behaviors is implemented in the views.
The model should not now about the presenter, this is the more loosely coupled approach.