Hello! In the conclusion of the Model View Presenter in Android series, we’ll talk about:
- How to implement MVP using the library simple-mvp to speed up your production process
- Common hiccups when using MVP in Android
If you missed the anterior articles, or want to understand the Model View Presenter concept in more detail, you can read it here:
Using the simple-mvp library
The simple-mvp library was implemented using Dr. Douglas C. Schmidt concept. The code follows the canonical form principles, hence it doesn’t use any library or resource from outside the Android SDK. There are some requirements that must be followed to the framework work properly.
simple-mvpis still an experimental library created for education purposes.
Some methods and operations may change until its maturity.
Quick setupadd build.gradle compile ‘com.tinmegali.mvp:mvp:0.0.7’ Create interfaces to communicate between MVP layers
- interface RequiredViewOps extends ActivityView
with VIEW methods to be accessed by PRESENTER
- interface ProvidedPresenterOps extends PresenterOps
Operations offered to VIEW to communicate with PRESENTER
- interface RequiredPresenterOps
with Required PRESENTER methods available to MODEL
- interface ProvidedModelOps extends ModelOps
Operations offered to MODEL to communicate with PRESENTER
class MODEL extends GenericModel implements MVP_MainActivity.ProvidedModelOpsVIEW layer of MVP pattern
class VIEW_Activity extends GenericMVPActivity<MVP_MainActivity.RequiredViewOps, MVP_MainActivity.ProvidedPresenterOps, MainPresenter> implements MVP_MainActivity.RequiredViewOpsCould also extend GenericMVPFragment PRESENTER from Model View Presenter (MVP) Pattern.
class MainPresenter extends GenericPresenter<MVP_MainActivity.RequiredPresenterOps, MVP_MainActivity.ProvidedModelOps, MVP_MainActivity.RequiredViewOps, MainModel> implements MVP_MainActivity.RequiredPresenterOps, MVP_MainActivity.ProvidedPresenterOps