You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by GitBox <gi...@apache.org> on 2018/12/27 02:28:28 UTC

[GitHub] zshshr closed pull request #276: * [doc] Update extends android

zshshr closed pull request #276: * [doc] Update extends android
URL: https://github.com/apache/incubator-weex-site/pull/276
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/docs/api/android-apis.md b/docs/docs/api/android-apis.md
index 2ec67b3d7..81e20c068 100644
--- a/docs/docs/api/android-apis.md
+++ b/docs/docs/api/android-apis.md
@@ -6,183 +6,6 @@ order: 2.2
 version: 2.1
 ---
 
-
-
-# WXSDKEngine
-
-1. Register component
-2. Register module
-3. Set up various adapters
-
-## Register component
-
-### __registerComponent(type,class,appendTree)__
-
-- `return`(_bool_): register success
-- `type`(_String_): component's name,such as `div`
-- `class`(_Class_): ComponentClass,called when init component 
-- `appendTree`(_bool_): render option logic,default false
-	- if true,render compoent tree one-time
-	- if false,render component one by one
-
-usage:
-
-```
-WXSDKEngine.registerComponent("video", WXVideo.class, false);
-```
-
-### __registerComponent(holder,appendTree,...names)__
-
-- `return`(_bool_): register success
-- `holder`(_IFComponentHolder_): abstract factory designed for create Component, and __SimpleComponentHolder__ is the a simple way to achieve IFComponentHolder.
-- `appendTree`: see `registerComponent(type,class,appendTree)`
-- `names`(_String ..._): component's name in front end template file
-
-usage:
-
-```
-WXSDKEngine.registerComponent(
-              new SimpleComponentHolder(
-                      WXText.class,
-                      new WXText.Creator()
-              ),
-              false,
-              "text"
-      );
-```
-
-## Register module
-
-registerModule(moduleName,moduleClass)
-
-- `return`(_bool_): register success
-- `moduleName`(_String_): module name
-- `moduleClass`(_Class_): the Java class of the module, which provide a constructor with an empty parameter.
-
-使用方式:
-
-```
-WXSDKEngine.registerModule("picker", WXPickersModule.class);
-```
-
-## Set up various adapters
-
-### ImageAdapter
-Image adapter is responsible for loading images according to URLs. There are two types of image adapter:
-1. Loading a image to a view according to URL.
-1. Loading a image to a specified object according to URL.
-
-In order to use image component, one must implement the first adapter, while the second adapter is optional.
-
-#### IWXImgLoaderAdapter
-
-    public interface IWXImgLoaderAdapter {
-      void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);
-    }
-
- * `WXImageQuality` that the quality of the picture variables, take the following values `LOW`, `NORMAL`, `HIGH`, `ORIGINAL` picture quality in turn higher. The default is `LOW`.
- * `WXImageStrategy` is an extension class that indicates whether the image can be cut (isClipping) sharpening (isSharpen) placeholder (placeHolder) and so on.
-
-#### IDrawableLoaderAdapter
-This adapter is optional.
-
-    void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
-
-*  `DrawableTarget` is a object into where will load an image. `DrawableTarget` is one of `StaticTarget` or `AnimatedTarget`.
-
-### IWXHttpAdapter
-
-Weex custom `WXRequest` and `OnHttpListener`, Native reload interface can be obtained from the Request URL, Header and other parameters, the network request can be completed through `OnHttpListener` callback notification. Weex provides the default network request: `DefaultWXHttpAdapter`, using `HttpURLConnection` for network requests.
-
-The interface is defined as follows:
-
-```
-public interface IWXHttpAdapter {
-	void sendRequest(WXRequest request, OnHttpListener listener);
-}
-``` 
-
-#### WXRequest
-
-* `WXRequest` defines the parameters related to the network request, the request method, the request body, and the timeout time. Weex default timeout is 3s.
-
-#### OnHttpListener
-
-```
- interface OnHttpListener {
-
-    /**
-     * start request
-     */
-    void onHttpStart();
-
-    /**
-     * headers received
-     */
-    void onHeadersReceived(int statusCode,Map<String,List<String>> headers);
-
-    /**
-     * post progress
-     * @param uploadProgress
-     */
-    void onHttpUploadProgress(int uploadProgress);
-
-    /**
-     * response loaded length (bytes), full length should read from headers (content-length)
-     * @param loadedLength
-     */
-    void onHttpResponseProgress(int loadedLength);
-
-    /**
-     * http response finish
-     * @param response
-     */
-    void onHttpFinish(WXResponse response);
-  }
-```
-
-### IWXUserTrackAdapter
-Weex related performance data (first screen loading time, JS-Native communication time, dom update time, etc.) and other general information (JSLib file size, Weex SDK version number, etc.).
-
-```
-public interface IWXUserTrackAdapter {
-	void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);
-}
-```
-
-Native implementation interface can be obtained through `WXPerformance` and `params` corresponding information.
-
-### IActivityNavBarSetter
-Weex provided the ability of navigation through `WXNavigatorModule` which relys on IActivityNavBarSetter.
-
-Usage:
-
-```
-WXSDKEngine.setActivityNavBarSetter(new IActivityNavBarSetter(){});   
-```    
-
-### IWXStorageAdapter
-Weex provided the ability of local storage through `WXStorageModule` which depends on IWXStorageAdapter. One can use `DefaultWXStorage` as the default implementation of IWXStorageAdapter.
-
-
-### IWXJSExceptionAdapter
-IWXJSExceptionAdapter is used to handle weex exception.
-- DownLoadException
-- WhiteSceenException
-- JSException
-- DownGradeException
-
-```
-public interface IWXJSExceptionAdapter {
-  void onJSException(WXJSExceptionInfo exception);
-}
-```
-usage:
-
-```
-WXSDKEngine.setJSExcetptionAdapter(new TestExceptionAdapter());
-```
-
 # WXSDKInstace
 
 ## Custom events
diff --git a/docs/guide/extend/extend-android.md b/docs/guide/extend/extend-android.md
index e05cf4e4d..bde911ea8 100644
--- a/docs/guide/extend/extend-android.md
+++ b/docs/guide/extend/extend-android.md
@@ -8,9 +8,7 @@ version: 2.1
 
 <!-- toc -->
 
-Weex supports module-extend、component-extend and adapter-extend.
-
-## Extend module
+## Module extend
 
 1. Customize modules class must extend from WXModule.
 2. Extended method must add @JSMethod (uiThread = false or true) annotation, which determines whether the method is run on UI thread.
@@ -63,6 +61,20 @@ Now `event` moudle is avaiable in weex, use the module like this:
 </script>
 ```
 
+## Register module
+
+registerModule(moduleName,moduleClass)
+
+- `return`(_bool_): register success
+- `moduleName`(_String_): module name
+- `moduleClass`(_Class_): the Java class of the module, which provide a constructor with an empty parameter.
+
+使用方式:
+
+```
+WXSDKEngine.registerModule("picker", WXPickersModule.class);
+```
+
 ## Javascript callback
 
 If the module need implement a callback to javascript, you just add `JSCallback` argument to the method you want expose to javascript:
@@ -214,10 +226,46 @@ Use this component in weex DSL:
 </script>
 ```
 
+## Register component
+
+### __registerComponent(type,class,appendTree)__
 
-# Extend adapter
+- `return`(_bool_): register success
+- `type`(_String_): component's name,such as `div`
+- `class`(_Class_): ComponentClass,called when init component
+- `appendTree`(_bool_): render option logic,default false
+	- if true,render compoent tree one-time
+	- if false,render component one by one
 
-## ImagedownloadAdapter
+usage:
+
+```
+WXSDKEngine.registerComponent("video", WXVideo.class, false);
+```
+
+### __registerComponent(holder,appendTree,...names)__
+
+- `return`(_bool_): register success
+- `holder`(_IFComponentHolder_): abstract factory designed for create Component, and __SimpleComponentHolder__ is the a simple way to achieve IFComponentHolder.
+- `appendTree`: see `registerComponent(type,class,appendTree)`
+- `names`(_String ..._): component's name in front end template file
+
+usage:
+
+```
+WXSDKEngine.registerComponent(
+              new SimpleComponentHolder(
+                      WXText.class,
+                      new WXText.Creator()
+              ),
+              false,
+              "text"
+      );
+```
+
+## Extend adapter
+
+### ImagedownloadAdapter
 
 Weex SDK has no image download capability, you need to implement `IWXImgLoaderAdapter`.
 
@@ -258,6 +306,125 @@ public class ImageAdapter implements IWXImgLoaderAdapter {
   }
 }
 ```
+
+## Set up various adapters
+
+### ImageAdapter
+Image adapter is responsible for loading images according to URLs. There are two types of image adapter:
+1. Loading a image to a view according to URL.
+1. Loading a image to a specified object according to URL.
+
+In order to use image component, one must implement the first adapter, while the second adapter is optional.
+
+#### IWXImgLoaderAdapter
+
+    public interface IWXImgLoaderAdapter {
+      void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);
+    }
+
+ * `WXImageQuality` that the quality of the picture variables, take the following values `LOW`, `NORMAL`, `HIGH`, `ORIGINAL` picture quality in turn higher. The default is `LOW`.
+ * `WXImageStrategy` is an extension class that indicates whether the image can be cut (isClipping) sharpening (isSharpen) placeholder (placeHolder) and so on.
+
+#### IDrawableLoaderAdapter
+This adapter is optional.
+
+    void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
+
+*  `DrawableTarget` is a object into where will load an image. `DrawableTarget` is one of `StaticTarget` or `AnimatedTarget`.
+
+### IWXHttpAdapter
+
+Weex custom `WXRequest` and `OnHttpListener`, Native reload interface can be obtained from the Request URL, Header and other parameters, the network request can be completed through `OnHttpListener` callback notification. Weex provides the default network request: `DefaultWXHttpAdapter`, using `HttpURLConnection` for network requests.
+
+The interface is defined as follows:
+
+```
+public interface IWXHttpAdapter {
+	void sendRequest(WXRequest request, OnHttpListener listener);
+}
+```
+
+#### WXRequest
+
+* `WXRequest` defines the parameters related to the network request, the request method, the request body, and the timeout time. Weex default timeout is 3s.
+
+#### OnHttpListener
+
+```
+ interface OnHttpListener {
+
+    /**
+     * start request
+     */
+    void onHttpStart();
+
+    /**
+     * headers received
+     */
+    void onHeadersReceived(int statusCode,Map<String,List<String>> headers);
+
+    /**
+     * post progress
+     * @param uploadProgress
+     */
+    void onHttpUploadProgress(int uploadProgress);
+
+    /**
+     * response loaded length (bytes), full length should read from headers (content-length)
+     * @param loadedLength
+     */
+    void onHttpResponseProgress(int loadedLength);
+
+    /**
+     * http response finish
+     * @param response
+     */
+    void onHttpFinish(WXResponse response);
+  }
+```
+
+### IWXUserTrackAdapter
+Weex related performance data (first screen loading time, JS-Native communication time, dom update time, etc.) and other general information (JSLib file size, Weex SDK version number, etc.).
+
+```
+public interface IWXUserTrackAdapter {
+	void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);
+}
+```
+
+Native implementation interface can be obtained through `WXPerformance` and `params` corresponding information.
+
+### IActivityNavBarSetter
+Weex provided the ability of navigation through `WXNavigatorModule` which relys on IActivityNavBarSetter.
+
+Usage:
+
+```
+WXSDKEngine.setActivityNavBarSetter(new IActivityNavBarSetter(){});   
+```    
+
+### IWXStorageAdapter
+Weex provided the ability of local storage through `WXStorageModule` which depends on IWXStorageAdapter. One can use `DefaultWXStorage` as the default implementation of IWXStorageAdapter.
+
+
+### IWXJSExceptionAdapter
+IWXJSExceptionAdapter is used to handle weex exception.
+- DownLoadException
+- WhiteSceenException
+- JSException
+- DownGradeException
+
+```
+public interface IWXJSExceptionAdapter {
+  void onJSException(WXJSExceptionInfo exception);
+}
+```
+usage:
+
+```
+WXSDKEngine.setJSExcetptionAdapter(new TestExceptionAdapter());
+```
+
 ## Proguard Rules
 
 If you want to using proguard to protect your source code, please add the following rules to your profile:
diff --git a/docs/zh/docs/api/android-apis.md b/docs/zh/docs/api/android-apis.md
index 4e29f4fdb..2b8d144ff 100644
--- a/docs/zh/docs/api/android-apis.md
+++ b/docs/zh/docs/api/android-apis.md
@@ -6,211 +6,6 @@ order: 2.2
 version: 2.1
 ---
 
-
-
-# WXSDKEngine
-
-1. 注册module 
-2. 注册component
-3. 设置自定义的adapter
-
-
-## 注册Component
-
-### __registerComponent(type,class,appendTree)__
-
-- `return`(_bool_): 是否注册成功
-- `type`(_String_): 前端使用的对应标签
-- `class`(_Class_): 组件的class,在创建组件实例时调用
-- `appendTree`(_bool_): 渲染时判定逻辑,默认false
-	- 如果为true,则这个组件的子组件,整颗树建立、layout完后,整体一起刷新。
-	- 如果为false,则这个组件的子组件,每add一个,刷新一个。
-
-使用方式:
-
-```
-WXSDKEngine.registerComponent("video", WXVideo.class, false);
-```
-
-### __registerComponent(holder,appendTree,...names)__
-
-- `return`(_bool_): 是否注册成功
-- `holder`(_IFComponentHolder_): 用于创建component的抽象工厂,默认使用__SimpleComponentHolder__。
-- `appendTree`: 同上
-- `names`(_String ..._): 前端使用的对应标签
-
-使用方式:
-
-```
-WXSDKEngine.registerComponent(
-              new SimpleComponentHolder(
-                      WXText.class,
-                      new WXText.Creator()
-              ),
-              false,
-              "text"
-      );
-```
-
-
-## 注册Module
-
-registerModule(moduleName,moduleClass)
-
-- `return`(_bool_): 是否注册成功
-- `moduleName`(_String_): 模块名称
-- `moduleClass`(_Class_): 模块对应的class,创建module实例时使用
-
-使用方式:
-
-```
-WXSDKEngine.registerModule("picker", WXPickersModule.class);
-```
-
-## 注册Adapter
-
-### ImageAdapter
-
-__WEEX和图片库完全解耦__,WEEX的图片加载,都是通过调用公共接口,由实现类决定调用哪个图片库
-
-- `IWXImgLoaderAdapter`: 根据url,load图片给某个view
-- `IDrawableLoader`(可选): 根据url,load图片给某个drawable.
-
-
-#### IWXImgLoaderAdapter
-
-```
-public interface IWXImgLoaderAdapter {
-	void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);   
-}
-```
-
-* `WXImageQuality` 图片质量的设置参数,有 `LOW`, `NORMAL`, `HIGH`, `ORIGINAL` 几种质量,默认为`LOW`.
-* `WXImageStrategy` 是一个扩展类参数,配置图像是否可以剪切`isClipping`、锐化`isSharpen`以及配置占位符`placeHolder`
-
-#### IDrawableLoader(可选)
-
-```
-  interface DrawableTarget {
-
-  }
-
-  interface StaticTarget extends DrawableTarget{
-    void setDrawable(@Nullable Drawable drawable, boolean resetBounds);
-  }
-
-  interface AnimatedTarget extends DrawableTarget{
-    void setAnimatedDrawable(@Nullable Drawable drawable);
-  }
-
-  void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
-}
-```
-
-
-### IWXHttpAdapter
-
-同`ImageAdapter`,__WEEX和网络库也是解耦的__,通过接口形式调用,由实现类决定调用哪个网络库。
-
-```
-public interface IWXHttpAdapter {
-	void sendRequest(WXRequest request, OnHttpListener listener);
-}
-``` 
-
-#### WXRequest
-
-- `paramMap`(_Map<String, String>_): http自定义请求参数,比如(?a=1&b=2);
-- `url`(_String_): http请求的目标url
-- `method`(_String_): http请求方法 "post","get"
-- `body`(_String_): http请求body
-- `timeoutMs`(_int_): 请求超时时间,__默认是3s__
-- `instanceId`(_String_): (页面)id
-
-
-#### OnHttpListener
-
-```
-interface OnHttpListener {
-
-	/**
-	*  开始请求
-	*/
-	void onHttpStart();
-
-	/**
-	* 收到http header内容
-	*/
-	void onHeadersReceived(int statusCode,Map<String,List<String>> headers);
-
-	/**
-	* 
-	* @param 上传进度
-	*/
-	void onHttpUploadProgress(int uploadProgress);
-
-	/**
-	* 
-	* @param loadedLength 接收到的数据长度
-	*/
-	void onHttpResponseProgress(int loadedLength);
-
-	/**
-	* 请求结束
-	* @param response 返回的response
-	*/
-	void onHttpFinish(WXResponse response);
-}
-```
-
-### IWXUserTrackAdapter(可选)
-
-打点相关,如果关注weex的打点,需要实现这个adapter
-- 基础信息:sdk版本、jsbundle大小...
-- 性能信息:sdk初始化时间、页面加载可交互时间、加载bundle时间...
-
-```
-public interface IWXUserTrackAdapter {
-	void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);
-}
-```
-
-### IActivityNavBarSetter
-
-`WXNavigatorModule`的实现依赖这个接口,用来操作navigation.
-
-使用方式:
-
-```
-WXSDKEngine.setActivityNavBarSetter(new IActivityNavBarSetter(){});   
-``` 
-
-### IWXStorageAdapter
-
-`WXStorageModule`实现依赖这个接口,用来实现数据的存、取默认使用`DefaultWXStorage`实现
-
-
-### IWXJSExceptionAdapter
-
-WEEX的异常上报接口,包括
-
-- 下载异常
-- 白屏异常
-- js异常
-- 降级异常
-
-```
-public interface IWXJSExceptionAdapter {
-  void onJSException(WXJSExceptionInfo exception);
-}
-```
-
-使用方式:
-
-```
-WXSDKEngine.setJSExcetptionAdapter(new TestExceptionAdapter());
-```
-
 # WXSDKInstace
 
 Weex Native 和 JavaScript 世界交互通信.
diff --git a/docs/zh/guide/extend/extend-android.md b/docs/zh/guide/extend/extend-android.md
index eeb55c3b1..0c541a1d6 100644
--- a/docs/zh/guide/extend/extend-android.md
+++ b/docs/zh/guide/extend/extend-android.md
@@ -1,18 +1,32 @@
+---
+title: 扩展 Android 的功能
+type: guide
+group: 扩展
+order: 6.2
+version: 2.1
+---
+
+<!-- toc -->
+
 Weex 提供了扩展机制,可以根据自己的业务进行定制自己的功能。
-主要分为:
-- Module 扩展, 非 UI 的特定功能。例如 sendHttp、openURL 等。
-- Component 扩展, 实现特别功能的 Native 控件。例如:RichTextview,RefreshListview 等。
-- Adapter 扩展, Weex 对一些基础功能实现了统一的接口,可实现这些接口来定制自己的业务。例如:图片下载等。
+主要分为两类扩展:
+
+- Module 扩展 非 UI 的特定功能。例如 sendHttp、openURL 等。
+- Component 扩展 实现特别功能的 Native 控件。例如:RichTextview,RefreshListview 等。
+- Adapter 扩展 Weex 对一些基础功能实现了统一的接口,可实现这些接口来定制自己的业务。例如:图片下载等。
+
 
 ## Module 扩展
+
 1. Module 扩展必须继承 WXModule 类。
-2. 扩展方法必须加上 `@JSMethod (uiThread = false or true)` 注解。Weex 会根据注解来判断当前方法是否要运行在 UI 线程,和当前方法是否是扩展方法。
+2. 扩展方法必须加上`@JSMethod (uiThread = false or true)` 注解。Weex 会根据注解来判断当前方法是否要运行在 UI 线程,和当前方法是否是扩展方法。
 3. Weex是根据反射来进行调用 Module 扩展方法,所以Module中的扩展方法必须是 public 类型。
 4. 同样因为是通过反射调用,Module 不能被混淆。请在混淆文件中添加代码:`-keep public class * extends com.taobao.weex.common.WXModule{*;}`
 5. Module 扩展的方法可以使用 int, double, float, String, Map, List 类型的参数
 6. 完成 Module 后一定要在初始化时注册 `WXSDKEngine.registerModule("myModule", MyModule.class);` 否则会报类似错误:`ReportException :undefined:9: TypeError: Object #<Object> has no method 'printLog'`
 
 示例如下:
+
 ```java
 public class MyModule extends WXModule {
 
@@ -30,11 +44,13 @@ public class MyModule extends WXModule {
 }
 ```
 Register the module
-```
+
+```java
 WXSDKEngine.registerModule("MyModule", MyModule.class);
 ```
-S 调用如下:
-```vue
+JS 调用如下:
+
+```html
 <template>
   <div>
     <text onclick="click">testMyModule</text>
@@ -52,14 +68,84 @@ S 调用如下:
 </script>
 ```
 
-## Component 扩展
+## Module 注册
+
+registerModule(moduleName,moduleClass)
+
+- `return`(_bool_): 是否注册成功
+- `moduleName`(_String_): 模块名称
+- `moduleClass`(_Class_): 模块对应的class,创建module实例时使用
+
+使用方式:
+
+```
+WXSDKEngine.registerModule("picker", WXPickersModule.class);
+```
+
+## Component 扩展(version > 0.19.0)
+### 1. 变更说明
+WXDomObject 和 Layout 引擎被下沉到 WeexCore 中使用 C++ 实现,移除 Java 代码中的 WXDomObject。此次变更涉及 WXComponent 和 WXDomObject 的适配。
+
+#### (1)setMeasureFunction 迁移
+WXDomObject 中的 setMeasureFunction() 方法迁移至 WXComponent 中:
+```java
+protected void setMeasureFunction(final ContentBoxMeasurement contentBoxMeasurement);
+```
+详见:com.taobao.weex.layout.ContentBoxMeasurement.java
+
+ContentBoxMeasurement 示例请参考:WXText.java / setMeasureFunction()
+注意:ContentBoxMeasurement 只支持叶子节点。
+
+#### (2)WXComponent 接口变更
+##### getDomObject [移除]
+由于 WXDomObject 下沉至 WeexCore 中,所以 getDomObject() 方法已被删除。
+
+##### 构造方法 [参数变更]
+WXComponent 的构造方法删除了类型为 WXDomObject 的参数,新增了类型为 BasicComponentData 的参数,其余参数保持不变:
+```java
+public WXComponent(WXSDKInstance instance, WXVContainer parent, int type, BasicComponentData basicComponentData);
+
+public WXComponent(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData);
+
+```
+
+#### (3)WXDomObject 接口变更
+你无法在Java代码中访问和继承 WXDomObject,( ImmutableDomObject 接口也已被删除)
+
+WXDomObject 的部分方法被迁移至 WXComponent中,如需使用,如下:
+
+##### WXDomObject.getType() -> WXComponent.getComponentType() [迁移]
+WXDomObject 中 的 getType() 方法用于获取组件类型(如:list、div、text、img...),迁移到 WXComponent 后,更名为:
+```java
+public String getComponentType();
+```
+
+##### 获取 Layout 结果的相关方法 [迁移]
+获取 Layout 结果的6个方法从 WXDomObject 迁移至 WXComponent:
+```java
+public float getCSSLayoutTop();
+public float getCSSLayoutBottom();
+public float getCSSLayoutLeft();
+public float getCSSLayoutRight();
+public float getLayoutWidth();
+public float getLayoutHeight();
+```
+
+移除两个废弃接口:
+```java
+public float getLayoutY();
+public float getLayoutX();
+```
+## Component 扩展(version< 0.19.0)
+
 1. Component 扩展类必须继承 WXComponent.
 2. Component 对应的设置属性的方法必须添加注解 @WXComponentProp(name=value(value is attr or style of dsl))
-3. Weex sdk 通过反射调用对应的方法,所以 Component 对应的属性方法必须是 public,并且不能被混淆。请在混淆文件中添加代码 `-keep public class * extends com.taobao.weex.ui.component.WXComponent{*;}`
+3. Weex sdk 通过反射调用对应的方法,所以 Component 对应的属性方法必须是 public,并且不能被混淆。请在混淆文件中添加代码  `-keep public class * extends com.taobao.weex.ui.component.WXComponent{*;}`
 4. Component 扩展的方法可以使用 int, double, float, String, Map, List 类型的参数
 5. 完成 Component 后一定要在初始化时注册 `WXSDKEngine.registerComponent("richText", RichText.class);`
 
-示例如下:
+示例如下:
+
 ```java
 public class RichText extends WXComponent<TextView> {
 
@@ -82,10 +168,13 @@ public class RichText extends WXComponent<TextView> {
 }
 ```
 注册你的组件:
-```
+
+```java
 WXSDKEngine.registerComponent("richText", RichText.class);
 ```
+
 JS 调用如下:
+
 ```html
 <template>
   <div>
@@ -93,33 +182,75 @@ JS 调用如下:
   </div>
 </template>
 ```
-
-### 组件方法支持
+#### 组件方法支持
 从WeexSDK 0.9.5开始,你可以定义组件方法
+
 - 在组件中如下声明一个组件方法
-  ```java
-  @JSMethod
-  public void focus(){
+
+ ```java
+ @JSMethod
+ public void focus(){
   //method implementation
-  }
-  ```
+ }
+ ```
+
 - 注册组之后,你可以在weex 文件中调用
-  ```vue
-  <template>
+
+  ```html
+	<template>
     <mycomponent ref='mycomponent'></mycomponent>
-  </template>
-  <script>
+	</template>
+	<script>
     module.exports = {
       created: function() {
         this.$refs.mycomponent.focus();
       }
     }
-  </script>
-  ```
+	</script>
+	```
+
 注:工程要添加依赖 `compile 'com.squareup.picasso:picasso:2.5.2'`
 
-## Adapter扩展
-图片下载:
+## Component 注册
+
+### __registerComponent(type,class,appendTree)__
+
+- `return`(_bool_): 是否注册成功
+- `type`(_String_): 前端使用的对应标签
+- `class`(_Class_): 组件的class,在创建组件实例时调用
+- `appendTree`(_bool_): 渲染时判定逻辑,默认false
+	- 如果为true,则这个组件的子组件,整颗树建立、layout完后,整体一起刷新。
+	- 如果为false,则这个组件的子组件,每add一个,刷新一个。
+
+使用方式:
+
+```
+WXSDKEngine.registerComponent("video", WXVideo.class, false);
+```
+
+### __registerComponent(holder,appendTree,...names)__
+
+- `return`(_bool_): 是否注册成功
+- `holder`(_IFComponentHolder_): 用于创建component的抽象工厂,默认使用__SimpleComponentHolder__。
+- `appendTree`: 同上
+- `names`(_String ..._): 前端使用的对应标签
+
+使用方式:
+
+```
+WXSDKEngine.registerComponent(
+              new SimpleComponentHolder(
+                      WXText.class,
+                      new WXText.Creator()
+              ),
+              false,
+              "text"
+      );
+```
+
+## Adapter 扩展
+
+### 图片库Adapter
 
 需要时集成接口 IWXImgLoaderAdapter,实现 setImage 方法。
 
@@ -162,8 +293,153 @@ public class ImageAdapter implements IWXImgLoaderAdapter {
 }
 ```
 
-### SDK混淆规则
+## Adapter 注册
+
+### ImageAdapter
+
+__WEEX和图片库完全解耦__,WEEX的图片加载,都是通过调用公共接口,由实现类决定调用哪个图片库
+
+- `IWXImgLoaderAdapter`: 根据url,load图片给某个view
+- `IDrawableLoader`(可选): 根据url,load图片给某个drawable.
+
+
+#### IWXImgLoaderAdapter
+
+```
+public interface IWXImgLoaderAdapter {
+	void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);   
+}
+```
+
+* `WXImageQuality` 图片质量的设置参数,有 `LOW`, `NORMAL`, `HIGH`, `ORIGINAL` 几种质量,默认为`LOW`.
+* `WXImageStrategy` 是一个扩展类参数,配置图像是否可以剪切`isClipping`、锐化`isSharpen`以及配置占位符`placeHolder`
+
+#### IDrawableLoader(可选)
+
+```
+  interface DrawableTarget {
+
+  }
+
+  interface StaticTarget extends DrawableTarget{
+    void setDrawable(@Nullable Drawable drawable, boolean resetBounds);
+  }
+
+  interface AnimatedTarget extends DrawableTarget{
+    void setAnimatedDrawable(@Nullable Drawable drawable);
+  }
+
+  void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
+}
+```
+
+
+### IWXHttpAdapter
+
+同`ImageAdapter`,__WEEX和网络库也是解耦的__,通过接口形式调用,由实现类决定调用哪个网络库。
+
+```
+public interface IWXHttpAdapter {
+	void sendRequest(WXRequest request, OnHttpListener listener);
+}
+```
+
+#### WXRequest
+
+- `paramMap`(_Map<String, String>_): http自定义请求参数,比如(?a=1&b=2);
+- `url`(_String_): http请求的目标url
+- `method`(_String_): http请求方法 "post","get"
+- `body`(_String_): http请求body
+- `timeoutMs`(_int_): 请求超时时间,__默认是3s__
+- `instanceId`(_String_): (页面)id
+
+
+#### OnHttpListener
+
+```
+interface OnHttpListener {
+
+	/**
+	*  开始请求
+	*/
+	void onHttpStart();
+
+	/**
+	* 收到http header内容
+	*/
+	void onHeadersReceived(int statusCode,Map<String,List<String>> headers);
+
+	/**
+	*
+	* @param 上传进度
+	*/
+	void onHttpUploadProgress(int uploadProgress);
+
+	/**
+	*
+	* @param loadedLength 接收到的数据长度
+	*/
+	void onHttpResponseProgress(int loadedLength);
+
+	/**
+	* 请求结束
+	* @param response 返回的response
+	*/
+	void onHttpFinish(WXResponse response);
+}
+```
+
+### IWXUserTrackAdapter(可选)
+
+打点相关,如果关注weex的打点,需要实现这个adapter
+- 基础信息:sdk版本、jsbundle大小...
+- 性能信息:sdk初始化时间、页面加载可交互时间、加载bundle时间...
+
+```
+public interface IWXUserTrackAdapter {
+	void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);
+}
+```
+
+### IActivityNavBarSetter
+
+`WXNavigatorModule`的实现依赖这个接口,用来操作navigation.
+
+使用方式:
+
+```
+WXSDKEngine.setActivityNavBarSetter(new IActivityNavBarSetter(){});   
+```
+
+### IWXStorageAdapter
+
+`WXStorageModule`实现依赖这个接口,用来实现数据的存、取默认使用`DefaultWXStorage`实现
+
+
+### IWXJSExceptionAdapter
+
+WEEX的异常上报接口,包括
+
+- 下载异常
+- 白屏异常
+- js异常
+- 降级异常
+
+```
+public interface IWXJSExceptionAdapter {
+  void onJSException(WXJSExceptionInfo exception);
+}
+```
+
+使用方式:
+
+```
+WXSDKEngine.setJSExcetptionAdapter(new TestExceptionAdapter());
+```
+
+#### SDK混淆规则
 若要在APP中使用混淆,请在相应的配置文件中添加如下规则:
+
 ```java
 -keep class com.taobao.weex.WXDebugTool{*;}
 -keep class com.taobao.weex.devtools.common.LogUtil{*;}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services