MVP实现思路

来源:互联网 发布:微信种植系统源码下载 编辑:程序博客网 时间:2024/05/16 18:43
MainActivity
有一个getData的方法
里面new presenter
presenter里有一个方法getViewurl(String url),这个方法里new Model,调Model的实现方法。还要传Mainctivity
给一个有参构造器,在实现的方法里面调Mainctivity实现的方法
molde里传一个presenter,给一个有参构造器
在molde本来的方法里写OK的封装
然后调presenter实现的方法
然后在Mainctivity实现的方法里写解析


先写接口
MyView里getperesenter(String json)
MyModel里getpresenterurl(String url)
MyPresenter里getmodel(String json)


Model实现MyModel
Presenter实现MyPresenter
View实现MyView


Mainctivity里new Presenter,调Presenter自己的方法
Presenter里new Model,调Model实现的方法,还要传一个Mainctivity,在Presenter自己的方法里调Mainctivity实现的方法
Model里传Presenter,调Presenter实现的方法



原创粉丝点击