weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ky...@apache.org
Subject [27/52] [abbrv] incubator-weex git commit: * [android] Add stacksize-limit for overdraw.
Date Mon, 07 May 2018 07:53:00 GMT
* [android] Add stacksize-limit for overdraw.


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/cddba7fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/cddba7fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/cddba7fe

Branch: refs/heads/master
Commit: cddba7fe326e7471d00cb49fc2c34dc31d24ad75
Parents: 0c9dfa3
Author: miomin <691292118@qq.com>
Authored: Sat Apr 28 17:54:17 2018 +0800
Committer: YorkShen <shenyuancs@gmail.com>
Committed: Mon May 7 15:52:08 2018 +0800

----------------------------------------------------------------------
 .../java/com/taobao/weex/common/Constants.java  |  2 ++
 .../taobao/weex/ui/component/WXComponent.java   | 10 ++++++
 .../com/taobao/weex/ui/component/WXDiv.java     | 28 ++++++++++++++++
 .../taobao/weex/ui/component/WXVContainer.java  |  3 ++
 .../com/taobao/weex/ui/view/WXFrameLayout.java  | 34 ++++++++++++--------
 5 files changed, 64 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cddba7fe/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
index 8f4b440..cd50b3f 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
@@ -189,6 +189,8 @@ public class Constants {
     String ARIA_HIDDEN = "ariaHidden";
     String ROLE = "role";
 
+    String STACKSIZE_LIMIT = "stacksizeLimit";
+
     String DIRECTION = "direction";
     String RTL = "rtl";
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cddba7fe/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index 55fd843..4f28a7f 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -170,6 +170,16 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent
imple
 
   private boolean waste = false;
 
+  private boolean hasStackSizeLimit = false;
+
+  protected void setStackSizeLimit(boolean hasStackSizeLimit) {
+    this.hasStackSizeLimit = hasStackSizeLimit;
+  }
+
+  public boolean isStackSizeLimit() {
+    return hasStackSizeLimit;
+  }
+
   private ContentBoxMeasurement contentBoxMeasurement;
   private WXTransition mTransition;
   private GraphicSize mPseudoResetGraphicSize;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cddba7fe/android/sdk/src/main/java/com/taobao/weex/ui/component/WXDiv.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXDiv.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXDiv.java
index b9f5ada..b485db5 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXDiv.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXDiv.java
@@ -20,8 +20,12 @@ package com.taobao.weex.ui.component;
 
 import android.content.Context;
 import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.widget.ImageView;
+
 import com.taobao.weex.WXSDKInstance;
 import com.taobao.weex.annotation.Component;
+import com.taobao.weex.common.Constants;
 import com.taobao.weex.ui.ComponentCreator;
 import com.taobao.weex.ui.action.BasicComponentData;
 import com.taobao.weex.ui.flat.FlatComponent;
@@ -114,4 +118,28 @@ public class WXDiv extends WidgetContainer<WXFrameLayout> implements
FlatCompone
   public boolean isVirtualComponent() {
     return !promoteToView(true);
   }
+
+  @WXComponentProp(name = Constants.Name.STACKSIZE_LIMIT)
+  public void setStackSizeLimitModle(String stackSizeLimit) {
+    setStackSizeLimit(getStackSizeLimit(stackSizeLimit));
+  }
+
+  private boolean getStackSizeLimit(String stackSizeLimit) {
+    boolean ret = false;
+    if (TextUtils.isEmpty(stackSizeLimit)) {
+      return ret;
+    }
+
+    switch (stackSizeLimit) {
+      case "true":
+        ret = true;
+        break;
+      case "false":
+        ret = false;
+        break;
+      default:
+        break;
+    }
+    return ret;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cddba7fe/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
index 3fb3915..346387c 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
@@ -268,6 +268,9 @@ public abstract class WXVContainer<T extends ViewGroup> extends
WXComponent<T> {
     } else {
       mChildren.add(index, child);
     }
+
+    if (isStackSizeLimit())
+      child.setStackSizeLimit(true);
   }
 
   public final int indexOf(WXComponent comp) {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cddba7fe/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java
index fce7dcc..56dc205 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java
@@ -96,20 +96,28 @@ public class WXFrameLayout extends FrameLayout implements WXGestureObservable,IR
 
   @Override
   protected void dispatchDraw(Canvas canvas) {
-    try {
-      if (mWidgets != null) {
-        canvas.save();
-        canvas.translate(getPaddingLeft(), getPaddingTop());
-        for (Widget widget : mWidgets) {
-          widget.draw(canvas);
-        }
-        canvas.restore();
-      } else {
-        WXViewUtils.clipCanvasWithinBorderBox(this, canvas);
-        super.dispatchDraw(canvas);
+    if (getComponent() != null && getComponent().isStackSizeLimit()) {
+      dispatchDrawInterval(canvas);
+    } else {
+      try {
+        dispatchDrawInterval(canvas);
+      }catch (Throwable e){
+        WXLogUtils.e("FlatGUI Crashed when dispatchDraw", WXLogUtils.getStackTrace(e));
       }
-    }catch (Throwable e){
-      WXLogUtils.e("FlatGUI Crashed when dispatchDraw", WXLogUtils.getStackTrace(e));
+    }
+  }
+
+  private void dispatchDrawInterval(Canvas canvas) {
+    if (mWidgets != null) {
+      canvas.save();
+      canvas.translate(getPaddingLeft(), getPaddingTop());
+      for (Widget widget : mWidgets) {
+        widget.draw(canvas);
+      }
+      canvas.restore();
+    } else {
+      WXViewUtils.clipCanvasWithinBorderBox(this, canvas);
+      super.dispatchDraw(canvas);
     }
   }
 }


Mime
View raw message