weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From misa...@apache.org
Subject [2/4] incubator-weex git commit: * [android] prevent NPE
Date Wed, 27 Sep 2017 10:09:36 GMT
* [android] prevent NPE


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

Branch: refs/heads/0.16-dev
Commit: 2c75a84128a262f770e026acf6236ab8d152ee54
Parents: 0839ee1
Author: misakuo <misakuo@apache.org>
Authored: Wed Sep 27 17:10:24 2017 +0800
Committer: misakuo <misakuo@apache.org>
Committed: Wed Sep 27 17:10:24 2017 +0800

----------------------------------------------------------------------
 .../java/com/taobao/weex/utils/BoxShadowUtil.java     | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2c75a841/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java b/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java
index c1cc693..892e80c 100644
--- a/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java
+++ b/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java
@@ -40,6 +40,7 @@ import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewParent;
 
 import com.taobao.weex.WXEnvironment;
 
@@ -147,7 +148,9 @@ public class BoxShadowUtil {
     shadowPaint.setColor(shadowColor);
     shadowPaint.setStyle(Paint.Style.FILL);
 
-    shadowPaint.setMaskFilter(new BlurMaskFilter(shadowRadius, BlurMaskFilter.Blur.NORMAL));
+    if (shadowRadius > 0) {
+      shadowPaint.setMaskFilter(new BlurMaskFilter(shadowRadius, BlurMaskFilter.Blur.NORMAL));
+    }
 
     Path shadowPath = new Path();
     float[] shadowRadii = new float[8];
@@ -186,8 +189,13 @@ public class BoxShadowUtil {
       target.getOverlay().clear();
       target.getOverlay().add(shadowDrawable);
       //Relayout to ensure the shadows are fully drawn
-      target.getParent().requestLayout();
-      ((ViewGroup) target.getParent()).invalidate(shadowDrawable.getBounds());
+      ViewParent parent = target.getParent();
+      if (parent != null) {
+        parent.requestLayout();
+        if (parent instanceof ViewGroup) {
+          ((ViewGroup) parent).invalidate(shadowDrawable.getBounds());
+        }
+      }
     } else {
       // I have a dream that one day our minSdkVersion will equals or higher than 21
       Log.w("BoxShadowUtil", "Call setNormalBoxShadow() requires API level 18 or higher.");


Mime
View raw message