I recently started building an android application and I would like to use an design pattern right from the scratch. I was told that MVP (Model-View-Presenter) is a good pattern for android applications.
I was wondering if it's possible to implement the "Passive View" variant of the MVP pattern? If I could, I would show any code.. but right now I have no idea how a passive view should look like in an android application. Also.. which role would play the MainActivity in a passive view scenario?
I would appreciate any explanations, tutorials or examples on how to implement a passive view.


MVP pattern in Android suggests that your View classes (Fragments, Activities) don't contain any presentation or business logic, but all logic is delegated to a Presenter class. The Presenter in turn calls usually
voidmethods provided by the View when the View is initialised, an event occurs, or the View is destroyed.So imagine a View and a Presenter implementing the following interfaces:
In our simplistic example the View would initialise the Presenter (dependency injection is out of scope of this post) and then call Presenter's
initViewmethod. The Presenter would be responsible for all initialisation logic like fetching data from network / storage and, if need be, update the View. When in turn the user clicks a button the View would delegate action to the Presenter by calling Presenter'sonButtonClicked()method. The Presenter can do some processing and depending on the outcome maybe call View'ssetTextColor()method.The most important reason for using MVP is to be able to test your logic with Junit and a mocking framework like Mockito. Your Presenter should be written in pure Java or Kotlin without any dependencies on the Android framework library. Then you can just test your Presenter by using the JVM and not having to hook up a device. This is all part of uncle Bob's clean architecture guidelines.
The two best resources for MVP are the Antonio Leiva's blog post and Google's architecture samples in github