MVP,抽取Controller中业务逻辑独立到Presenter,解决Controller臃肿,View与Presenter间通过Interface交互,代码逻辑更加清晰,同时Presenter更方便写单元测试;
架构设计:
架构实现:
View
View抽象接口
|
|
Fragment实现
|
|
Activity实现
|
|
Presenter
Presenter抽象接口
|
|
Presenter基类
|
|
使用实例:
Contact接口,内部类方式定义View和Presenter接口
|
|
Presenter使用,继承ZZBasePresenter,同时实现Contact.Presenter接口
|
|
Fragment实现,继承ZZBaseFragment,同时实现Contact.View接口
|
|
Activity实现,继承ZZBaseActivity,同时实现Contact.View接口
|
|