# TODO-MVP
### Summary
This sample is the base for many of the variants. It showcases a simple
implementation of the Model-View-Presenter pattern with no architectural
frameworks. It uses manual dependency injection to provide a repository with
local and remote data sources. Asynchronous tasks are handled with callbacks.
<img src="https://github.com/googlesamples/android-architecture/wiki/images/mvp.png" alt="Diagram"/>
Note: in a MVP context, the term "view" is overloaded:
* The class android.view.View will be referred to as "Android View"
* The view that receives commands from a presenter in MVP, will be simply called
"view".
### Fragments
It uses fragments for two reasons:
* The separation between Activity and Fragment fits nicely with this
implementation of MVP: the Activity is the overall controller that creates and
connects views and presenters.
* Tablet layout or screens with multiple views take advantage of the Fragments
framework.
### Key concepts
There are four features in the app:
* <code>Tasks</code>
* <code>TaskDetail</code>
* <code>AddEditTask</code>
* <code>Statistics</code>
Each feature has:
* A contract defining the view and the presenter
* An Activity which is responsible for the creation of fragments and presenters
* A Fragment which implements the view interface.
* A presenter which implements the presenter interface
In general, the business logic lives in the presenter and relies on the view to
do the Android UI work.
The view contains almost no logic: it converts the presenter's commands to UI
actions and listens to user actions, which are passed to the presenter.
Contracts are interfaces used to define the connection between views and
presenters.
### Dependencies
* Common Android support libraries (<code>com.android.support.\*)</code>
* Android Testing Support Library (Espresso, AndroidJUnitRunner…)
* Mockito
* Guava (null checking)
## Features
### Complexity - understandability
#### Use of architectural frameworks/libraries/tools:
None
#### Conceptual complexity
Low, as it's a pure MVP implementation for Android
### Testability
#### Unit testing
High, presenters are unit tested as well as repositories and data sources.
#### UI testing
High, injection of fake modules allow for testing with fake data
### Code metrics
Compared to a traditional project with no architecture in place, this sample
introduces additional classes and interfaces: presenters, a repository,
contracts, etc. So lines of code and number of classes are higher in MVP.
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Java 46 1075 1451 3451
XML 34 97 337 601
-------------------------------------------------------------------------------
SUM: 80 1172 1788 4052
-------------------------------------------------------------------------------
```
### Maintainability
#### Ease of amending or adding a feature
High.
#### Learning cost
Low. Features are easy to find and the responsibilities are clear. Developers
don't need to be familiar with any external dependency to work on the project.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
google 官方android mvp demo (106个子文件)
gradlew.bat 2KB
.gitignore 99B
.gitignore 7B
build.gradle 4KB
build.gradle 864B
settings.gradle 15B
gradlew 5KB
gradle-wrapper.jar 49KB
TasksScreenTest.java 16KB
TasksRepositoryTest.java 15KB
TasksFragment.java 14KB
TasksRepository.java 10KB
TasksLocalDataSourceTest.java 8KB
TasksLocalDataSource.java 8KB
TasksPresenter.java 8KB
TaskDetailPresenterTest.java 8KB
TasksPresenterTest.java 7KB
TaskDetailFragment.java 7KB
TaskDetailScreenTest.java 6KB
TasksActivity.java 5KB
NavigationViewActions.java 5KB
TasksRemoteDataSource.java 5KB
AddEditTaskPresenterTest.java 5KB
StatisticsActivity.java 5KB
StatisticsPresenterTest.java 5KB
TaskDetailPresenter.java 4KB
AppNavigationTest.java 4KB
AddEditTaskFragment.java 4KB
StatisticsScreenTest.java 4KB
StatisticsPresenter.java 4KB
Task.java 4KB
AddEditTaskScreenTest.java 4KB
FakeTasksRemoteDataSource.java 4KB
AddEditTaskPresenter.java 3KB
AddEditTaskActivity.java 3KB
StatisticsFragment.java 3KB
SimpleCountingIdlingResource.java 3KB
TaskDetailActivity.java 3KB
TasksContract.java 2KB
TasksDbHelper.java 2KB
TasksDataSource.java 2KB
TestUtils.java 2KB
ScrollChildSwipeRefreshLayout.java 2KB
Injection.java 2KB
TaskDetailContract.java 2KB
ActivityUtils.java 2KB
Injection.java 2KB
TasksPersistenceContract.java 1KB
AddEditTaskContract.java 1KB
EspressoIdlingResource.java 1KB
StatisticsContract.java 1KB
TasksFilterType.java 1007B
BaseView.java 751B
BasePresenter.java 735B
LICENSE 11KB
README.md 3KB
CONTRIBUTING.md 2KB
logo.png 15KB
logo.png 12KB
logo.png 7KB
logo.png 5KB
ic_launcher.png 5KB
logo.png 4KB
ic_launcher.png 4KB
ic_launcher.png 3KB
ic_launcher.png 2KB
ic_launcher.png 1KB
proguard-rules.pro 797B
proguardTest-rules.pro 374B
gradle.properties 855B
gradle-wrapper.properties 231B
tasks_frag.xml 3KB
tasks_act.xml 3KB
strings.xml 3KB
addtask_act.xml 3KB
taskdetail_act.xml 2KB
statistics_act.xml 2KB
taskdetail_frag.xml 2KB
addtask_frag.xml 2KB
AndroidManifest.xml 2KB
task_item.xml 2KB
nav_header.xml 1KB
statistics_frag.xml 1KB
styles.xml 1KB
tasks_fragment_menu.xml 1KB
styles.xml 1KB
dimens.xml 1KB
ic_edit.xml 1KB
drawer_actions.xml 1KB
filter_tasks.xml 1015B
dimens.xml 980B
colors.xml 966B
taskdetail_fragment_menu.xml 945B
ic_assignment_turned_in_24dp.xml 601B
ic_statistics_100dp.xml 476B
ic_verified_user_24dp.xml 461B
ic_check_circle_24dp.xml 422B
ic_statistics_24dp.xml 410B
ic_statistics.xml 410B
ic_list.xml 362B
共 106 条
- 1
- 2
资源评论
- xiaoyushibaba2016-10-31下载看看不知道怎么样
- 金钟罩第十二关2017-09-18好用,基本上能看懂
- 何小小09032018-07-24不错的分享,学习了,谢谢!
Carling丶卡林
- 粉丝: 2
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 高等数学第一章第二节数列的极限
- Python 版冒泡排序算法源代码
- tensorflow-gpu-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-2.7.3-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp39-cp39-manylinux2010-x86-64.whl
- Python版本快速排序源代码
- Python 语言版的快速排序算法实现
- 450815388207377安卓_base.apk
- 超微主板 X9DRE-TF+ bios 支持 nvme启动
- 基于Python通过下载气象数据和插值拟合离散数据曲线实现对寒潮过程的能量分析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功