Skip to content

Sync #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from Jul 16, 2015
Merged

Sync #44

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tech/animation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,13 @@ together (default) :动画同时启动

属性
android:propertyName:
String 类型,必须要设定的值,代表要执行动画的属性,通过名字引用,比如你可以指定了一个 View 的"alpha" 或者 "backgroundColor" ,这个 objectAnimator 元素没有暴露 target 属性,因此不能够在 XML 中执行一个动画,必须通过调用`loadAnimator()` 填充你的 XML 动画资源,并且调用`setTarget()` 应用到拥有这个属性的目标对象上。
String 类型,必须要设定的值,代表要执行动画的属性,通过名字引用,比如你可以指定了一个 View 的"alpha" 或者 "backgroundColor",这个 objectAnimator 元素没有暴露 target 属性,因此不能够在 XML 中执行一个动画,必须通过调用`loadAnimator()` 填充你的 XML 动画资源,并且调用`setTarget()` 应用到拥有这个属性的目标对象上。

`android:valueTo`
Float、int 或者 color,也是必须值,表明了动画结束的点,颜色由 6 位十六进制的数字表示。

`android:valueFrom`
相对应 valueTo,动画的起始点,如果没有指定,系统会通过属性身上的 get 方法获取 ,颜色也是 6 位十六进制的数字表示。
相对应 valueTo,动画的起始点,如果没有指定,系统会通过属性身上的 get 方法获取,颜色也是 6 位十六进制的数字表示。

`android:duration`
动画的时长,int 类型,以毫秒为单位,默认为 300 毫秒。
Expand Down
8 changes: 4 additions & 4 deletions tech/annotation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ MethodInfo Annotation 作用为给方法添加相关信息,包括 author、dat
这里是 MethodInfo 的实现部分
(1). 通过 @interface 定义,注解名即为自定义注解名
(2). 注解配置参数名为注解类的方法名,且:
a. 所有方法没有方法体,没有参数没有修饰符,实际只允许 public & abstract 修饰符,默认为 public ,不允许抛异常
a. 所有方法没有方法体,没有参数没有修饰符,实际只允许 public & abstract 修饰符,默认为 public,不允许抛异常
b. 方法返回值只能是基本类型,String, Class, annotation, enumeration 或者是他们的一维数组
c. 若只有一个默认属性,可直接用 value() 函数。一个属性都没有表示该 Annotation 为 Mark Annotation
(3). 可以加 default 表示默认值
Expand Down Expand Up @@ -219,7 +219,7 @@ process 函数返回值表示这组 annotations 是否被这个 Processor 接受

[RestMethodInfo.java](https://github.com/square/retrofit/blob/master/retrofit/src/main/java/retrofit/RestMethodInfo.java) 的 parseMethodAnnotations 方法如上,会检查每个方法的每个 Annotation, 看是否被 RestMethod 这个 Annotation 修饰的 Annotation 修饰,这个有点绕,就是是否被 GET、DELETE、POST、PUT、HEAD、PATCH 这些 Annotation 修饰,然后得到 Annotation 信息,在对接口进行动态代理时会掉用到这些 Annotation 信息从而完成调用。

Retrofit 原理涉及到[动态代理](http://codekk.com/open-source-project-analysis/detail/Android/Caij/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8BJava%20%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86),这里原理都只介绍 Annotation,具体原理分析请见 [Android 开源项目实现原理解析](http://www.codekk.com)
Retrofit 原理涉及到[动态代理](http://codekk.com/open-source-project-analysis/detail/Android/Caij/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8B%20Java%20%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86),这里原理都只介绍 Annotation,具体原理分析请见 [Android 开源项目实现原理解析](http://codekk.com/open-source-project-analysis)

#### 6.2 Annotation — Butter Knife
(1) 调用
Expand Down Expand Up @@ -262,7 +262,7 @@ Retrofit 原理涉及到[动态代理](http://codekk.com/open-source-project-ana


[ButterKnifeProcessor.java](https://github.com/JakeWharton/butterknife/blob/master/butterknife/src/main/java/butterknife/internal/ButterKnifeProcessor.java) 的 process 方法如上,编译时,在此方法中过滤 InjectView 这个 Annotation 到 targetClassMap 后,会根据 targetClassMap 中元素生成不同的 class 文件到最终的 APK 中,然后在运行时调用 ButterKnife.inject(x) 函数时会到之前编译时生成的类中去找。
这里原理都只介绍 Annotation,具体原理分析请见 [Android 开源项目实现原理解析](http://www.codekk.com)
这里原理都只介绍 Annotation,具体原理分析请见 [Android 开源项目实现原理解析](http://codekk.com/open-source-project-analysis)

#### 6.3 Annotation — ActiveAndroid
(1) 调用
Expand Down Expand Up @@ -301,5 +301,5 @@ Retrofit 原理涉及到[动态代理](http://codekk.com/open-source-project-ana

[TableInfo.java](https://github.com/pardom/ActiveAndroid/blob/master/src/com/activeandroid/TableInfo.java) 的构造函数如上,运行时,得到所有行信息并存储起来用来构件表信息。

这里原理都只介绍 Annotation,具体原理分析请见 [Android 开源项目实现原理解析](http://www.codekk.com)
这里原理都只介绍 Annotation,具体原理分析请见 [Android 开源项目实现原理解析](http://codekk.com/open-source-project-analysis)

4 changes: 2 additions & 2 deletions tech/touch-event/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

附上两张原文中流程图:
(1) View 不处理事件流程图
![view-ignore-touch-event-example](https://farm6.staticflickr.com/5529/13927155020_73bdfab805_o.jpg)
![view-ignore-touch-event-example](image/ignorant-view-example.jpg)

(2) View 处理事件流程图
![view-process-touch-event-example](https://farm8.staticflickr.com/7062/14110505861_6569e33985_o.jpg)
![view-process-touch-event-example](image/interested-view-example.jpg)
Binary file added tech/touch-event/image/ignorant-view-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions tech/viewdrawflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#### View 绘制机制
#####1. View 树的绘图流程
当 Activity 接收到焦点的时候,它会被请求绘制布局,该请求由 Android framework 处理.绘制是从根节点开始,对布局树进行 measure 和 draw 。整个 View 树的绘图流程在`ViewRoot.java`类的`performTraversals()`函数展开,该函数所做 的工作可简单概况为是否需要重新计算视图大小(measure)、是否需要重新安置视图的位置(layout)、以及是否需要重绘(draw),流程图如下:
当 Activity 接收到焦点的时候,它会被请求绘制布局,该请求由 Android framework 处理.绘制是从根节点开始,对布局树进行 measure 和 draw。整个 View 树的绘图流程在`ViewRoot.java`类的`performTraversals()`函数展开,该函数所做 的工作可简单概况为是否需要重新计算视图大小(measure)、是否需要重新安置视图的位置(layout)、以及是否需要重绘(draw),流程图如下:
![viewdrawflow img](image/view_mechanism_flow.png)

**View 绘制流程函数调用链**
Expand All @@ -22,10 +22,10 @@
树的遍历是有序的,由父视图到子视图,每一个 ViewGroup 负责测绘它所有的子视图,而最底层的 View 会负责测绘自身。

**具体分析**
measure 过程由`measure(int, int)`方法发起,从上到下有序的测量 View ,在 measure 过程的最后,每个视图存储了自己的尺寸大小和测量规格。
measure 过程由`measure(int, int)`方法发起,从上到下有序的测量 View,在 measure 过程的最后,每个视图存储了自己的尺寸大小和测量规格。
layout 过程由`layout(int, int, int, int)`方法发起,也是自上而下进行遍历。在该过程中,每个父视图会根据 measure 过程得到的尺寸来摆放自己的子视图。

measure 过程会为一个 View 及所有子节点的 mMeasuredWidth 和 mMeasuredHeight 变量赋值,该值可以通过 `getMeasuredWidth()`和`getMeasuredHeight()`方法获得。而且这两个值必须在父视图约束范围之内,这样才可以保证所有的父视图都接收所有子视图的测量。如果子视图对于 Measure 得到的大小不满意的时候,父视图会介入并设置测量规则进行第二次 measure。比如,父视图可以先根据未给定的 dimension 去测量每一个子视图,如果最终子视图的未约束尺寸太大或者太小的时候,父视图就会使用一个确切的大小再次对子视图进行 measure
measure 过程会为一个 View 及所有子节点的 mMeasuredWidth 和 mMeasuredHeight 变量赋值,该值可以通过 `getMeasuredWidth()`和`getMeasuredHeight()`方法获得。而且这两个值必须在父视图约束范围之内,这样才可以保证所有的父视图都接收所有子视图的测量。如果子视图对于 Measure 得到的大小不满意的时候,父视图会介入并设置测量规则进行第二次 measure。比如,父视图可以先根据未给定的 dimension 去测量每一个子视图,如果最终子视图的未约束尺寸太大或者太小的时候,父视图就会使用一个确切的大小再次对子视图进行 measure。

**measure 过程传递尺寸的两个类**
- ViewGroup.LayoutParams (View 自身的布局参数)
Expand All @@ -38,7 +38,7 @@ ViewGroup.LayoutParams
- WRAP_CONTENT 表示视图为正好能包裹其内容大小(包含 padding 值)

ViewGroup 的子类有其对应的 ViewGroup.LayoutParams 的子类。比如 RelativeLayout 拥有的 ViewGroup.LayoutParams 的子类 RelativeLayoutParams。
有时我们需要使用 view.getLayoutParams() 方法获取一个视图 LayoutParams ,然后进行强转,但由于不知道其具体类型,可能会导致强转错误。其实该方法得到的就是其所在父视图类型的 LayoutParams,比如 View 的父控件为 RelativeLayout,那么得到的 LayoutParams 类型就为 RelativeLayoutParams。
有时我们需要使用 view.getLayoutParams() 方法获取一个视图 LayoutParams,然后进行强转,但由于不知道其具体类型,可能会导致强转错误。其实该方法得到的就是其所在父视图类型的 LayoutParams,比如 View 的父控件为 RelativeLayout,那么得到的 LayoutParams 类型就为 RelativeLayoutParams。

MeasureSpecs
测量规格,包含测量要求和尺寸的信息,有三种模式:
Expand Down Expand Up @@ -70,7 +70,7 @@ MeasureChild 的方法调用流程图:
```java
/**
* 请求所有子 View 去 measure 自己,要考虑的部分有对子 View 的测绘要求 MeasureSpec 以及其自身的 padding
* 这里跳过所有为 GONE 状态的子 View ,最繁重的工作是在 getChildMeasureSpec 方法中处理的
* 这里跳过所有为 GONE 状态的子 View,最繁重的工作是在 getChildMeasureSpec 方法中处理的
*
* @param widthMeasureSpec 对该 View 的 width 测绘要求
* @param heightMeasureSpec 对该 View 的 height 测绘要求
Expand Down
4 changes: 2 additions & 2 deletions tool-lib/common/xutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ xUtils 一个 Android 公共库框架,主要包括四个部分:View,Db, Ht
#####2.1.2 流程图
![流程图](image/view_sque.png)
#####2.1.3 核心类功能介绍
######请先了解[注解](http://www.codekk.com/open-source-project-analysis/detail/Android/Trinea/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8B%20Java%20%E6%B3%A8%E8%A7%A3%20Annotation) ,[动态代理](http://www.codekk.com/open-source-project-analysis/detail/Android/Caij/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8B%20Java%20%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86) 可以帮助到您, 如果已经了解请忽略。
######请先了解[注解](http://www.codekk.com/open-source-project-analysis/detail/Android/Trinea/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8B%20Java%20%E6%B3%A8%E8%A7%A3%20Annotation),[动态代理](http://www.codekk.com/open-source-project-analysis/detail/Android/Caij/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7%82%B9%E4%B9%8B%20Java%20%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86) 可以帮助到您, 如果已经了解请忽略。
注解和反射知识是这个模块的主要内容
#####1.ViewUtils.java
View 和各种事件的注入以及资源的注入。
Expand Down Expand Up @@ -345,7 +345,7 @@ private BitmapCache bitmapCache;
- 2.通过 handler 进行线程通信

####不同点:
- 1. Volley 的 Http 请求在 android 2.3 版本之前是通过 HttpClient ,在之后的版本是通过 URLHttpConnection。xUtils 都是通过 HttpClient 请求网络(bitmap 模块图片下载是通过 URLHttpConnection)。 URLHttpConnection 默认支持 GZIP 压缩,api 操作简单。
- 1. Volley 的 Http 请求在 android 2.3 版本之前是通过 HttpClient,在之后的版本是通过 URLHttpConnection。xUtils 都是通过 HttpClient 请求网络(bitmap 模块图片下载是通过 URLHttpConnection)。 URLHttpConnection 默认支持 GZIP 压缩,api 操作简单。
- 2.Volley 将 Http 请求数据先缓存进 byte[], 然后是分配给不同的请求转化为需要的格式。xUtils 是直接转化为想要的格式。 Volley:扩展性好, 但是不能存在大数据请求,否则就 OOM。xUtils:不缓存入 byte[] 支持大数据的请求, 速度比 Volley 稍快,但扩展性就低。
- 4.Volley 访问网络数据时直接开启固定个数线程访问网络, 在 run 方法中执行死循环, 阻塞等待请求队列。 xUtils 是开启线程池来管理线程。
- 5. 缓存失效策略, volley 的所有网络数据支持从 http 响应头中控制是否缓存和读取缓存失效时间,每个请求可以控制是否缓存和缓存失效时间。 Xutils 网络数据请求是统一自定义缓存失效时间。
Expand Down
2 changes: 1 addition & 1 deletion tool-lib/compatibility/nineoldanimations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ colorAnim.start();


**示例 3:**
动画集合,5 秒内对 View 的旋转、平移、缩放和透明度都进行了改变
动画集合,5 秒内对 View 的旋转、平移、缩放和透明度都进行了改变。

```
AnimatorSet set = new AnimatorSet();
Expand Down
2 changes: 1 addition & 1 deletion tool-lib/dependency-injection/dagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bindings 数据结构为 HashMap,value 就是具体的 Binding,key 是用来
连接(Link):从 DAG 的角度说,就是把某个节点与其所依赖的各个节点连接起来。而对于 Binding 来说,就是把当前 Binding 和它依赖的 Binding (`ProvidesBinding`)进行连接,即初始化这个 Binding 依赖的所有 Binding,使它们可用。

#####(3). attachSuccess
一个标志,对于某个 Binding,在获取它依赖的`DependencyBinding`时,如果他所有的`DependencyBinding`都已经添加到`Binding`库中,attachSuccess 则为 true,否则为 false。如果为 false ,表示该 Binding 尚未连接,添加到待连接队列中,否则标记为已连接。
一个标志,对于某个 Binding,在获取它依赖的`DependencyBinding`时,如果他所有的`DependencyBinding`都已经添加到`Binding`库中,attachSuccess 则为 true,否则为 false。如果为 false,表示该 Binding 尚未连接,添加到待连接队列中,否则标记为已连接。

#####(4). linkedBindings
默认为 null,只有在 linkAll() 函数被调用后才有效,用于存储所有已经连接的 Binding,同时也是一个标记,表示这个 ObjectGraph 已经不能被改变。
Expand Down
2 changes: 1 addition & 1 deletion view/image-view/photoview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ OnGestureListener 接口回调的实现方法.
以上 3 个类并不实际执行 放大/缩小 行为, 判断行为之后会回调给 PhtotViewAttacher 执行缩放/移动操作

##### 4.1.14 VersionedGestureDetector
提供 GestureDetector 的实例,由它根据系统版本决定实例化哪一个 GestureDetector ,主要是为了兼容 Android 的不同版本。
提供 GestureDetector 的实例,由它根据系统版本决定实例化哪一个 GestureDetector,主要是为了兼容 Android 的不同版本。
具体调用栈请参考总体设计中调用流程图,注意一点,PhotoViewAttacher 本身就实现了 OnGestureListener 接口,实际的缩放操作是由 PhotoViewAttacher 完成的,而不是这里声明的各个 GestureDetector.


Expand Down
Loading