weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sospar...@apache.org
Subject [1/3] incubator-weex git commit: * [android] fix the incorrect image size
Date Thu, 04 May 2017 05:54:56 GMT
Repository: incubator-weex
Updated Branches:
  refs/heads/0.13-dev b33a2fea4 -> 59062f36c


* [android] fix the incorrect image size


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

Branch: refs/heads/0.13-dev
Commit: 73f1038f6a1ed82f84b983a404447350a24bb778
Parents: 42f2a85
Author: moxun.ljf <furmint@foxmail.com>
Authored: Wed May 3 11:17:41 2017 +0800
Committer: moxun.ljf <furmint@foxmail.com>
Committed: Wed May 3 11:17:41 2017 +0800

----------------------------------------------------------------------
 .../com/taobao/weex/ui/view/WXImageView.java    | 31 +++++++++++++++++---
 1 file changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/73f1038f/android/sdk/src/main/java/com/taobao/weex/ui/view/WXImageView.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/WXImageView.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/WXImageView.java
index 32baa00..dd7b2bc 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/view/WXImageView.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/WXImageView.java
@@ -32,6 +32,7 @@ import com.taobao.weex.ui.component.WXImage;
 import com.taobao.weex.ui.view.gesture.WXGesture;
 import com.taobao.weex.ui.view.gesture.WXGestureObservable;
 import com.taobao.weex.utils.ImageDrawable;
+import com.taobao.weex.utils.WXLogUtils;
 
 import java.lang.ref.WeakReference;
 import java.util.Arrays;
@@ -130,8 +131,19 @@ public class WXImageView extends ImageView implements WXGestureObservable,
   @Override
   public int getNaturalWidth() {
     Drawable drawable = getDrawable();
-    if (drawable != null && drawable instanceof ImageDrawable) {
-      return ((ImageDrawable) drawable).getBitmapWidth();
+    if (drawable != null) {
+      if (drawable instanceof ImageDrawable) {
+        return ((ImageDrawable) drawable).getBitmapWidth();
+      } else if (drawable instanceof BitmapDrawable) {
+        Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
+        if (bitmap != null) {
+          return bitmap.getWidth();
+        } else {
+          WXLogUtils.w("WXImageView", "Bitmap on " + drawable.toString() + " is null");
+        }
+      } else {
+        WXLogUtils.w("WXImageView", "Not supported drawable type: " + drawable.getClass().getSimpleName());
+      }
     }
     return -1;
   }
@@ -139,8 +151,19 @@ public class WXImageView extends ImageView implements WXGestureObservable,
   @Override
   public int getNaturalHeight() {
     Drawable drawable = getDrawable();
-    if (drawable != null && drawable instanceof ImageDrawable) {
-      return ((ImageDrawable) drawable).getBitmapHeight();
+    if (drawable != null) {
+      if (drawable instanceof ImageDrawable) {
+        return ((ImageDrawable) drawable).getBitmapHeight();
+      } else if (drawable instanceof BitmapDrawable) {
+        Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
+        if (bitmap != null) {
+          return bitmap.getHeight();
+        } else {
+          WXLogUtils.w("WXImageView", "Bitmap on " + drawable.toString() + " is null");
+        }
+      } else {
+        WXLogUtils.w("WXImageView", "Not supported drawable type: " + drawable.getClass().getSimpleName());
+      }
     }
     return -1;
   }


Mime
View raw message