Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[android] Refactor Dom and Render code #104

Merged
merged 2 commits into from
Mar 15, 2017
Merged

Conversation

sospartan
Copy link
Contributor

No description provided.

@weex-bot
Copy link

Warnings
⚠️ Potential BREAK CHANGE. Modify public in android/sdk/src/main/java/com/taobao/weex/dom/WXDomManager.java
⚠️ Potential BREAK CHANGE. Modify public in android/sdk/src/main/java/com/taobao/weex/dom/WXDomModule.java
⚠️ Potential BREAK CHANGE. Modify public in android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java
⚠️ Potential BREAK CHANGE. Modify public in android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java
⚠️ Potential BREAK CHANGE. Modify public in android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java

Generated by 🚫 dangerJS

mBridgeManager = WXBridgeManager.getInstance();
}

static void initInstance(WXRenderManager renderManager){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

像getInstance一样,做个多线程保护?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个方法是给单测用的,不public


public class Actions {

public static DOMAction get(String actionName,JSONArray args){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get改成create更合理写

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

回头可以打算加pooling

}


public static DOMAction getInvokeMethod(String ref,String method,JSONArray args){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,get改为create

* Created by sospartan on 01/03/2017.
*/

public class Actions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

名字改成ActionCreator 或者 ActionFactory ?

@@ -319,24 +275,41 @@ public boolean handleMessage(Message msg) {

public static class MsgType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DomHandler有些冗余,消息会经过domModule -> domManger->domHandler->domManger这个序列传递,消息在domManager和DomHandler之间扔来扔去。

建议

  1. DomManger实现Handler.Callback
  2. WXDomHandler.handleMessage移动到DomManger.handleMessage
  3. DomHandler中仅保留public static class MsgType这个内部静态类

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为了尽量减少修改,执行的流程暂时不做修改。

@@ -256,9 +255,10 @@
* and {@link WXDomManager} is responsible for manage the relation of correspondence.
* </p>
*/
class WXDomStatement {
class WXDomStatement implements DOMActionContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WXDomstatement名字有些诡异,建议下列做法2选1

  • WXDomStatemtn改名为DomActionContextImp
  • 直接去掉DomActionContext这个接口,WXDomstatement改名为DomActionContext

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恩 这是接下来必然会发生的 不在这个PR里改了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改名我这次一起做掉,接口留着,这是为了解耦,否则容易退化

* Created by sospartan on 23/02/2017.
*/

class RenderTask implements IWXRenderTask {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

名字改为RenderActionAdatpter更合理

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interface是task

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个类的功能是把RenderAction转换为RenderTask,重名为RenderActionAdapter或RenderActionTask更容易理解。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"RenderActionTask",用来区分一下好了

*/

class RenderTask implements IWXRenderTask {
private final RenderAction mStatement;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mRednerAction

@@ -236,7 +232,7 @@
* This class is very similar to {@link com.taobao.weex.dom.WXDomStatement}
* @see com.taobao.weex.dom.WXDomStatement
*/
class WXRenderStatement {
class WXRenderStatement implements RenderActionContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

名字改为RenderActionContextImp更好些

 pential break changes: WXRenderStatement#getComponentSize,DomModule#getComponentSize. It's low risk since it's a internal method, users should not dirct use it.
@YorkShen
Copy link
Contributor

YorkShen commented Mar 15, 2017

Impressive.

May god bless this pr 😃 .

@asfgit asfgit merged commit 20f6c37 into apache:0.12-dev Mar 15, 2017
asfgit pushed a commit that referenced this pull request Mar 15, 2017
@sospartan sospartan deleted the new-stmt branch June 8, 2017 05:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants