YorkShen closed pull request #203: Update extend-android.md URL: https://github.com/apache/incubator-weex-site/pull/203
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/source/cn/guide/extend-android.md b/source/cn/guide/extend-android.md index 84d311da4..a615b0c95 100644 --- a/source/cn/guide/extend-android.md +++ b/source/cn/guide/extend-android.md @@ -15,6 +15,7 @@ Weex 提供了扩展机制,可以根据自己的业务进行定制自己的功 - Component 扩展 实现特别功能的 Native 控件。例如:RichTextview,RefreshListview 等。 - Adapter 扩展 Weex 对一些基础功能实现了统一的接口,可实现这些接口来定制自己的业务。例如:图片下载等。 + ## Module 扩展 1. Module 扩展必须继承 WXModule 类。 @@ -66,7 +67,65 @@ JS 调用如下: } </script> ``` -## Component 扩展 + +## 0.19.+ Component 扩展适配文档 + +### 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(); +``` + + +## 低于0.19版本的 Component 扩展 1. Component 扩展类必须继承 WXComponent. 2. Component 对应的设置属性的方法必须添加注解 @WXComponentProp(name=value(value is attr or style of dsl)) ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
