A Model View Presenter Library using plain and simple interfaces, based on concept from Dr. Douglas Schmidt
Attention:
simple-mvp
is still an experimental library created for education purposes.
Some methods and operations may change until its maturity.
Created by Tin Megali
- Step by step guide
-
Model View Presenter Tutorial series
Tutoriais também disponíveis em português - JavaDoc
-
add 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
-
-
Implement MVP objects extending its generics
- MODEL from Model View Presenter (MVP) pattern.
class MODEL extends GenericModel implements MVP_MainActivity.ProvidedModelOps
<li>VIEW layer of MVP pattern <br/> <code> class VIEW_Activity extends GenericMVPActivity<MVP_MainActivity.RequiredViewOps, MVP_MainActivity.ProvidedPresenterOps, MainPresenter> implements MVP_MainActivity.RequiredViewOps </code> <br /> <em>Could also extend <code>GenericMVPFragment</code></em> </li> <li>PRESENTER from Model View Presenter (MVP) Pattern. <br/> <code> class MainPresenter extends GenericPresenter<MVP_MainActivity.RequiredPresenterOps, MVP_MainActivity.ProvidedModelOps, MVP_MainActivity.RequiredViewOps, MainModel> implements MVP_MainActivity.RequiredPresenterOps, MVP_MainActivity.ProvidedPresenterOps </code> </li> </ul> </li>
- MODEL from Model View Presenter (MVP) pattern.
-
Crie as interfaces de comunicação entre os módulos View, Presenter e Model
-
interface
RequiredViewOps
fornece métodos paraPresenter
comunicar comView
. É necessário extenderActivityView
-
interface
ProvidedPresenterOps
fornece operações oferecidas ao layer View para comunicação com Presenter. É preciso extenderPresenterOps
-
interface
RequiredPresenterOps
operações oferecidas pelo layer Presenter para comunicações com Model -
interface
ProvidedModelOps
operações oferecidos pelo layer Model para comunicações com Presenter. É preciso extenderModelOps
-
interface
-
Crie a classe
Model
extendendoGenericModel
e implementandoProvidedModelOps
ex: {@link com.tinmegali.androidmvp.main.model.MainModel} -
Crie a classe
Presenter
extendendoGenericPresenter
, implementandoRequiredPresenterOps
eProvidedPresenterOps
. exemplo: {@link com.tinmegali.androidmvp.main.presenter.MainPresenter} -
Crie a classe
View
GenericMVPActivity ou GenericMVPFragment e implementandoRequiredViewOps
Exemplo: {@link com.tinmegali.androidmvp.main.view.MainActivity} .