You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by gu...@apache.org on 2017/10/19 04:33:37 UTC

[34/50] [abbrv] incubator-weex git commit: fix clipPath not works on android N 7.0

fix clipPath not works on android N 7.0


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

Branch: refs/heads/release
Commit: c2f1aac354c3640aa47942b8828883364eec14cd
Parents: 5957426
Author: 行久 <yi...@alibaba-inc.com>
Authored: Thu Oct 12 18:08:09 2017 +0800
Committer: gurisxie <27...@qq.com>
Committed: Wed Oct 18 12:07:46 2017 +0800

----------------------------------------------------------------------
 .../java/com/taobao/weex/utils/WXViewUtils.java | 25 ++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/c2f1aac3/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
index 7d11d5a..4a1b304 100644
--- a/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
+++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
@@ -378,7 +378,7 @@ public class WXViewUtils {
   public static void clipCanvasWithinBorderBox(View targetView, Canvas canvas) {
     Drawable drawable;
     if (clipCanvasDueToAndroidVersion(canvas) &&
-        clipCanvasIfAnimationExist() &&
+        clipCanvasIfAnimationExist(targetView) &&
         ((drawable = targetView.getBackground()) instanceof BorderDrawable)) {
       BorderDrawable borderDrawable = (BorderDrawable) drawable;
       if (borderDrawable.isRounded()) {
@@ -394,7 +394,7 @@ public class WXViewUtils {
   public static void clipCanvasWithinBorderBox(Widget widget, Canvas canvas) {
     BorderDrawable borderDrawable;
     if (clipCanvasDueToAndroidVersion(canvas) &&
-        clipCanvasIfAnimationExist() &&
+        clipCanvasIfAnimationExist(null) &&
         (borderDrawable=widget.getBackgroundAndBorder())!=null ) {
       if (borderDrawable.isRounded() && clipCanvasIfBackgroundImageExist(widget, borderDrawable)) {
           Path path = borderDrawable.getContentPath(
@@ -424,8 +424,25 @@ public class WXViewUtils {
    * As animation will not cause redraw if hardware-acceleration enabled, clipCanvas feature has
    * to be disabled when API level is 24 without considering the animation property.
    */
-  private static boolean clipCanvasIfAnimationExist() {
-    return Build.VERSION.SDK_INT != VERSION_CODES.N;
+  private static boolean clipCanvasIfAnimationExist(View targetView) {
+    if (Build.VERSION.SDK_INT != VERSION_CODES.N) {
+      return true;
+    }
+    if(targetView != null &&
+            targetView.getScaleX() == 1 &&
+            targetView.getScaleY() == 1 &&
+            targetView.getTranslationX() == 0 &&
+            targetView.getTranslationY() == 0 &&
+            targetView.getRotation() == 0 &&
+            targetView.getRotationX() == 0 &&
+            targetView.getRotationY() == 0) {
+      if(Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && targetView.getTranslationZ() != 0 ) {
+        return false;
+      } else {
+        return true;
+      }
+    }
+    return false;
   }
 
   /**