看了一些MVP架构的代码,画了下图帮助理解,图中implements和组合关系的线不准确,勿介意。


源码和参考:http://www.cnblogs.com/liuling/archive/2015/12/23/mvp-pattern-android.html
总结:这个例子是一个activity + 一个viewinterface + 一个model + 一个presenter 。对应的mvp都需要相应的接口来解耦。
扩展1:一个view + 一个viewinterface + 一个model + 一个presenter;
扩展2:一个activity + N个viewinterface + N个model + N个presenter;
扩展3:model层可以采用okhttp或者rxjava等框架。后续来完善这个。
网友评论