1.1 研究背景.....................................................................................................................1
1.2 Android 架构的现状和发展.......................................................................................1
1.2.1 Android 架构的初期状态.....................................................................................1
1.2.2 Android 4.0 之后,Fragment的引入.................................................................1
1.2.3 MVP &MVVM.....................................................................................................2
1.2.4 事件驱动编程.......................................................................................................2
1.2.5 RxJava 带来的革命..............................................................................................2
第二章架构需求分析.............................................................................3
2.1 需求目标.....................................................................................................................3
2.1.1 目标产品...............................................................................................................3
2.1.2 目标用户(开发者)................................................................................................3
2.2 开发需求.....................................................................................................................3
2.2.1 开发期的功能需求...............................................................................................3
2.2.2 开发期的质量需求...............................................................................................4
2.3 用户级需求.................................................................................................................4
2.3.1 用户级功能需求...................................................................................................4
2.3.2 运行期质量需求...................................................................................................5
2.4 需求总结.....................................................................................................................5
第三章架构整体设计.............................................................................6
3.1 架构逻辑设计.............................................................................................................6
3.1.1 架构图...................................................................................................................6
3.1.2 架构结构划分.......................................................................................................6
3.1.3 架构特点...............................................................................................................7
3.1.4 架构核心 Common..............................................................................................7
3.2 项目开发期间架构设计.............................................................................................9
3.2.1 工程结构...............................................................................................................9
3.2.2 使用本架构构建 App..........................................................................................9
3.2.3 编译期间依赖关系.............................................................................................11
3.2.4 模块隔离开发.....................................................................................................11
3.3 运行期间架构...........................................................................................................12
3.3.1 运行期间的模块加载升级.................................................................................12
3.3.2 运行期组件依赖.................................................................................................12
3.3.3 页面导航和业务服务导航.................................................................................12
第四章分层架构....................................................................................13
4.1 分层概述...................................................................................................................13
4.2 MVC 分层架构.........................................................................................................13
4.2.1 MVC 简介...........................................................................................................13
4.2.2 Model 模型层.....................................................................................................14
4.2.3 Controller 控制器...............................................................................................15
4.2.4 View 层...............................................................................................................15
4.2.5 MVC 所存在的问题...........................................................................................15
4.3 MVVM 分层架构.....................................................................................................17
4.3.1 MVVM 简介.......................................................................................................17
4.3.2 MVVM 各层.......................................................................................................17
4.3.3 DataBinding 原理简介.......................................................................................18
4.3.4 MVVM 缺点.......................................................................................................19
4.4 MVP 分层架构..........................................................................................................19
4.4.1 MVP 简介...........................................................................................................19
4.4.2 Model 层设计.....................................................................................................20
4.4.3 View 层设计.......................................................................................................20
4.4.3 Presenter 层设计.................................................................................................21
4.4.4 MVP 的统筹 协议层设计.................................................................................21
4.4.5 MVP 的优缺点...................................................................................................22
4.4.6 MVP 与 MVC的不同。..................................................................................22
第五章组件化........................................................................................24
5.1 组件化介绍...............................................................................................................24
5.2 本架构中组件的实现...............................................................................................24
5.3 Component 的依赖....................................................................................................25
5.4 Component 的生命周期............................................................................................25
5.5 MVPComponent........................................................................................................26
5.6 API Component..........................................................................................................27
5.7AppComponent...........................................................................................................28
5.7.1 AppComponent 含义..........................................................................................28
5.7.2 各个基础组件.....................................................................................................29
5.8 组件管理器 ComponentManager............................................................................31
第六章 DI 依赖注入.............................................................................33
6.1 依赖注入定义...........................................................................................................33
6.2 依赖注入意义...........................................................................................................33
6.3 Android 中的依赖注入 Dagger2.............................................................................34
6.3.1 简介.....................................................................................................................34
6.3.2 Dagger2 中的重要概念......................................................................................34
6.4 本架构中的依赖注入...............................................................................................35
6.4.1 MVP 三层依赖组装...........................................................................................35
6.4.2 App 全局组件依赖.............................................................................................36
6.4.3 业务组件依赖拼装.............................................................................................37
第七章 AOP 面向切面编程.................................................................40
7.1 AOP 的定义...............................................................................................................40
7.2 在 Android 上使用 Aspectj实现 AOP................................................................40
7.3 动态织入实现原理...................................................................................................41
7.4 AOP 在本架构中的使用...........................................................................................42
7.4.1 动态权限检测.....................................................................................................42
7.4.2 登陆检测.............................................................................................................43
7.4.3 性能检测 & Log................................................................................................43
7.4.4 异步与主线程.....................................................................................................44
第八章 Bundle 模块化容器化.............................................................46
8.1 定义...........................................................................................................................46
8.2 意义...........................................................................................................................46
8.3 Atlas &Small..............................................................................................................46
8.3.1 简介.....................................................................................................................46
8.3.2 原理.....................................................................................................................47
8.4 本架构中的模块化...................................................................................................48
第九章 Router 页面路由.....................................................................50
9.1 背景...........................................................................................................................50
9.2 Intent 导航遇到的问题.............................................................................................50
9.3 意义...........................................................................................................................50
9.4 页面路由的使用.......................................................................................................51
9.5 页面路由的原理及实现...........................................................................................52
9.5.1 页面发现.............................................................................................................52
9.5.2 页面分发.............................................................................................................53
第十章事件驱动....................................................................................54
10.1 事件驱动定义.........................................................................................................54
10.2 事件驱动意义.........................................................................................................54
10.3 事件驱动框架原理.................................................................................................54
10.4 事件框架的实现 EventPoster................................................................................56
10.4.1 EventPoster 优势简述......................................................................................56
10.4.2 模块 Handler 以及分发..................................................................................57
10.4.3 性能优化...........................................................................................................57
10.4.4 防止 Leak.........................................................................................................58
第十一章框架原理及实践...................................................................59
11.1 自己动手实现 JSON ORM 框架..........................................................................59
11.2 图像异步加载框架原理及实现.............................................................................63
11.2.1Cache..................................................................................................................63
11.2.2 线程池...............................................................................................................64
11.2.3 图片压缩...........................................................................................................64
11.2.4 其他优化...........................................................................................................64
11.3 Http 请求框架 Retrofit...........................................................................................65
11.3.1 原理...................................................................................................................65
11.3.2 源码分析...........................................................................................................65
第十二章案例实践...............................................................................68
12.1 案例简述-数读........................................................................................................68
12.2 需求简述-数读........................................................................................................68
12.3 重构之前的程序结构-数读....................................................................................68
12.4 重构后的程序结构-数读........................................................................................69
12.4.1 架构裁剪-数读.................................................................................................69
12.4.2 UML 类图-数读................................................................................................70
12.4.3 主要功能需求-数读.........................................................................................70
12.4.4 重构带来的改变...............................................................................................73
结 论....................................................................................................75
致谢........................................................................................................76
参考文献............................................................................................77