todo-mvp官方地址android
#UI层
项目主要实现了4部分功能:git
每一个功能都是依照以下方式实现:github
A presenter typically hosts business logic associated with a particular feature, and the corresponding view handles the Android UI work. The view contains almost no logic; it converts the presenter's commands to UI actions, and listens for user actions, which are then passed to the presenter.数据库
Presenter一般托管这与特定功能相关的业务逻辑,响应的View层处理Android UI工做。视图层几乎不包含逻辑;视图层把Presenter层中的命令转化为UI操做,并且视图层去监听用户的操做,传递给Presenter层。网络
项目中包含了Presenter,Repository和DataSource,实现层与层之间的解耦,同时方便单元测试。架构
按照Android-CleanArchitecture架构图来讲,这里只包含了Presentation Layer和Data Layer两层,并未包含Domain Layer。其依赖规则是只能上层依赖下层。单元测试
App须要的数据都是经过Data层中的Repository模块提供,由它去完成访问网络和数据库等。测试
使用Repository将业务层与具体的查询逻辑分离,Repository的实现类主要职责就是存储查询数据,一个更简单的解释就是你能够把Repository的实现类当成是一个Java容器(Collections),能够从中获取或存储数据(add/remove/etc),他对数据源进行了抽象。Data层的Repository只须要实现相关接口,并提供相关服务便可。google
如上图,Repository接口定义了getUserById、getAllUsers等方法,其实现类对接口作具体实现,而真正的操做多是经过Dao才能访问数据库,或者经过Okhttp访问网络url获取数据。url
回到todo项目中:
欢迎交流!