You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/04/13 05:17:01 UTC

[31/50] incubator-weex git commit: * [android] Fix opacity issue

* [android] Fix opacity issue


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

Branch: refs/heads/dev
Commit: 2deccfdbf761ce932c0c03c76454b532daf04148
Parents: c22d8e4
Author: YorkShen <sh...@gmail.com>
Authored: Wed Apr 12 15:57:03 2017 +0800
Committer: YorkShen <sh...@gmail.com>
Committed: Wed Apr 12 15:57:03 2017 +0800

----------------------------------------------------------------------
 .../main/java/com/taobao/weex/ui/component/WXComponent.java    | 6 ++++--
 .../src/test/java/com/taobao/weex/ui/component/WXTextTest.java | 5 ++---
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2deccfdb/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 52cad7c..5aa791a 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
@@ -1059,8 +1059,10 @@ public abstract class  WXComponent<T extends View> implements IWXObject, IWXActi
   }
 
   public void setOpacity(float opacity) {
-    if (opacity >= 0 && opacity <= 1 && mHost.getAlpha() != opacity && isLayerTypeEnabled()) {
-      mHost.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+    if (opacity >= 0 && opacity <= 1 && mHost.getAlpha() != opacity) {
+      if (isLayerTypeEnabled()) {
+        mHost.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+      }
       mHost.setAlpha(opacity);
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2deccfdb/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java
index 108a2e9..0181457 100644
--- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java
+++ b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java
@@ -26,9 +26,8 @@ import com.taobao.weex.dom.TestDomObject;
 import com.taobao.weex.dom.WXDomObject;
 import com.taobao.weex.dom.WXTextDomObject;
 import com.taobao.weex.dom.flex.Spacing;
-
 import com.taobao.weex.ui.SimpleComponentHolder;
-import org.apache.tools.ant.taskdefs.EchoXML;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -157,7 +156,7 @@ public class WXTextTest {
         prop.put(Constants.Name.OPACITY, 0.8f);
         mWXText.updateProperties(prop);
         assertTrue(mWXText.getHostView().isEnabled());
-        assertTrue(mWXText.getHostView().getAlpha()>=0.799 && mWXText.getHostView().getAlpha()<=0.811);
+        assertEquals(0.8f, mWXText.getHostView().getAlpha(), 0.001f);
 
         prop.put(Constants.Name.DISABLED, "true");
         mWXText.updateProperties(prop);