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/03/03 02:01:24 UTC
[1/5] incubator-weex git commit: * [android] provide image size by
imageview self
Repository: incubator-weex
Updated Branches:
refs/heads/0.11-dev 0e0e1f25e -> 2f99d1a65
* [android] provide image size by imageview self
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/5a285f05
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5a285f05
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5a285f05
Branch: refs/heads/0.11-dev
Commit: 5a285f05dd387ddf434e2f4735f054224132fea0
Parents: 1d60c41
Author: moxun.ljf <mo...@alibaba-inc.com>
Authored: Wed Mar 1 09:54:33 2017 +0800
Committer: moxun.ljf <mo...@alibaba-inc.com>
Committed: Wed Mar 1 09:54:33 2017 +0800
----------------------------------------------------------------------
.../com/taobao/weex/ui/component/WXImage.java | 11 ++++++++---
.../com/taobao/weex/ui/view/WXImageView.java | 20 +++++++++++++++++++-
2 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5a285f05/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
index d7a7e56..2e0ae65 100755
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
@@ -381,9 +381,9 @@ public class WXImage extends WXComponent<ImageView> {
if (getDomObject() != null && getDomObject().getEvents().contains(Constants.Event.ONLOAD)) {
Map<String, Object> params = new HashMap<String, Object>();
Map<String, Object> size = new HashMap<>(2);
- if (imageView != null && imageView.getDrawable() != null && imageView.getDrawable() instanceof ImageDrawable) {
- size.put("naturalWidth", ((ImageDrawable) imageView.getDrawable()).getBitmapWidth());
- size.put("naturalHeight", ((ImageDrawable) imageView.getDrawable()).getBitmapHeight());
+ if (imageView != null && imageView instanceof Measurable) {
+ size.put("naturalWidth", ((Measurable) imageView).getNaturalWidth());
+ size.put("naturalHeight", ((Measurable) imageView).getNaturalHeight());
} else {
size.put("naturalWidth", 0);
size.put("naturalHeight", 0);
@@ -443,4 +443,9 @@ public class WXImage extends WXComponent<ImageView> {
readyToRender();
}
}
+
+ public interface Measurable {
+ int getNaturalWidth();
+ int getNaturalHeight();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5a285f05/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 4c6bc04..1f049f5 100755
--- 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
@@ -223,7 +223,7 @@ import java.lang.ref.WeakReference;
import java.util.Arrays;
public class WXImageView extends ImageView implements WXGestureObservable,
- IRenderStatus<WXImage> {
+ IRenderStatus<WXImage>, WXImage.Measurable {
private WeakReference<WXImage> mWeakReference;
private WXGesture wxGesture;
@@ -305,4 +305,22 @@ public class WXImageView extends ImageView implements WXGestureObservable,
public void holdComponent(WXImage component) {
mWeakReference = new WeakReference<>(component);
}
+
+ @Override
+ public int getNaturalWidth() {
+ Drawable drawable = getDrawable();
+ if (drawable != null && drawable instanceof ImageDrawable) {
+ return ((ImageDrawable) drawable).getBitmapWidth();
+ }
+ return -1;
+ }
+
+ @Override
+ public int getNaturalHeight() {
+ Drawable drawable = getDrawable();
+ if (drawable != null && drawable instanceof ImageDrawable) {
+ return ((ImageDrawable) drawable).getBitmapHeight();
+ }
+ return -1;
+ }
}
[4/5] incubator-weex git commit: update testcase
Posted by so...@apache.org.
update testcase
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/cb0f31cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/cb0f31cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/cb0f31cd
Branch: refs/heads/0.11-dev
Commit: cb0f31cdd6a91180c97d7cd63845a3a8c6998324
Parents: 8893b95
Author: moxun.ljf <mo...@alibaba-inc.com>
Authored: Fri Mar 3 09:47:20 2017 +0800
Committer: moxun.ljf <mo...@alibaba-inc.com>
Committed: Fri Mar 3 09:47:20 2017 +0800
----------------------------------------------------------------------
test/scripts/components/image-onload.test.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cb0f31cd/test/scripts/components/image-onload.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/image-onload.test.js b/test/scripts/components/image-onload.test.js
index 8030511..f4622da 100644
--- a/test/scripts/components/image-onload.test.js
+++ b/test/scripts/components/image-onload.test.js
@@ -13,7 +13,7 @@ describe('image onload', function () {
before(function () {
return util.init(driver)
- .get('wxpage://' + util.getDeviceHost() +'/image.js')
+ .get('wxpage://' + util.getDeviceHost() +'/image-onload.js')
.waitForElementByXPath('//div/text[1]',util.getGETActionWaitTimeMills(),1000)
});
[5/5] incubator-weex git commit: Merge branch
'android-feature-getimagesize' of http://github.com/misakuo/incubator-weex
into 0.11-dev This closes #15
Posted by so...@apache.org.
Merge branch 'android-feature-getimagesize' of http://github.com/misakuo/incubator-weex into 0.11-dev
This closes #15
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/2f99d1a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/2f99d1a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/2f99d1a6
Branch: refs/heads/0.11-dev
Commit: 2f99d1a6580e7d8f2a75bd786e5b1b001f2422c4
Parents: 0e0e1f2 cb0f31c
Author: sospartan <so...@gmail.com>
Authored: Fri Mar 3 09:57:01 2017 +0800
Committer: sospartan <so...@gmail.com>
Committed: Fri Mar 3 09:57:01 2017 +0800
----------------------------------------------------------------------
.../com/taobao/weex/ui/component/WXImage.java | 11 ++++--
.../com/taobao/weex/ui/view/WXImageView.java | 20 +++++++++-
test/pages/image-onload.we | 19 ++++++++++
test/scripts/components/image-onload.test.js | 39 ++++++++++++++++++++
4 files changed, 85 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[3/5] incubator-weex git commit: update testcase
Posted by so...@apache.org.
update testcase
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/8893b95a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/8893b95a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/8893b95a
Branch: refs/heads/0.11-dev
Commit: 8893b95a9184caeab552bee316daddd34438b499
Parents: 26ad7ab
Author: moxun.ljf <mo...@alibaba-inc.com>
Authored: Fri Mar 3 09:30:53 2017 +0800
Committer: moxun.ljf <mo...@alibaba-inc.com>
Committed: Fri Mar 3 09:30:53 2017 +0800
----------------------------------------------------------------------
test/pages/image-onload.we | 19 +++++++++++
test/pages/image.we | 19 -----------
test/scripts/components/image-onload.test.js | 39 +++++++++++++++++++++++
test/scripts/components/image.test.js | 39 -----------------------
4 files changed, 58 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8893b95a/test/pages/image-onload.we
----------------------------------------------------------------------
diff --git a/test/pages/image-onload.we b/test/pages/image-onload.we
new file mode 100644
index 0000000..8d21c7a
--- /dev/null
+++ b/test/pages/image-onload.we
@@ -0,0 +1,19 @@
+<template>
+ <div>
+ <img style="width: 500;height: 500;" src="https://gw.alicdn.com/tps/TB1bEMYKXXXXXaLaXXXXXXXXXXX-360-388.png" onload="onload"></img>
+ <text style="font-size:30">{{size}}</text>
+ </div>
+</template>
+<script>
+ module.exports = {
+ data : {
+ size:"-1,-1"
+ },
+ methods : {
+ onload : function(e) {
+ nativeLog(JSON.stringify(e))
+ this.size = e.size.naturalWidth + ',' + e.size.naturalHeight;
+ }
+ }
+ }
+</script>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8893b95a/test/pages/image.we
----------------------------------------------------------------------
diff --git a/test/pages/image.we b/test/pages/image.we
deleted file mode 100644
index 8d21c7a..0000000
--- a/test/pages/image.we
+++ /dev/null
@@ -1,19 +0,0 @@
-<template>
- <div>
- <img style="width: 500;height: 500;" src="https://gw.alicdn.com/tps/TB1bEMYKXXXXXaLaXXXXXXXXXXX-360-388.png" onload="onload"></img>
- <text style="font-size:30">{{size}}</text>
- </div>
-</template>
-<script>
- module.exports = {
- data : {
- size:"-1,-1"
- },
- methods : {
- onload : function(e) {
- nativeLog(JSON.stringify(e))
- this.size = e.size.naturalWidth + ',' + e.size.naturalHeight;
- }
- }
- }
-</script>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8893b95a/test/scripts/components/image-onload.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/image-onload.test.js b/test/scripts/components/image-onload.test.js
new file mode 100644
index 0000000..8030511
--- /dev/null
+++ b/test/scripts/components/image-onload.test.js
@@ -0,0 +1,39 @@
+'use strict';
+
+var _ = require('macaca-utils');
+var assert = require('chai').assert
+var wd = require('weex-wd')
+var path = require('path');
+var os = require('os');
+var util = require("../util.js");
+
+describe('image onload', function () {
+ this.timeout(util.getTimeoutMills());
+ var driver = util.createDriver(wd);
+
+ before(function () {
+ return util.init(driver)
+ .get('wxpage://' + util.getDeviceHost() +'/image.js')
+ .waitForElementByXPath('//div/text[1]',util.getGETActionWaitTimeMills(),1000)
+ });
+
+ after(function () {
+ return util.quit(driver);
+ })
+
+
+ it('#1 download image', () => {
+ return driver
+ .sleep(5000)
+ .elementByXPath('//div/text')
+ .text()
+ .then((text)=>{
+ if(text == '-1,-1') {
+ return;
+ }
+ assert.equal(text, '360,388')
+ })
+ })
+});
+
+
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8893b95a/test/scripts/components/image.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/image.test.js b/test/scripts/components/image.test.js
deleted file mode 100644
index 8030511..0000000
--- a/test/scripts/components/image.test.js
+++ /dev/null
@@ -1,39 +0,0 @@
-'use strict';
-
-var _ = require('macaca-utils');
-var assert = require('chai').assert
-var wd = require('weex-wd')
-var path = require('path');
-var os = require('os');
-var util = require("../util.js");
-
-describe('image onload', function () {
- this.timeout(util.getTimeoutMills());
- var driver = util.createDriver(wd);
-
- before(function () {
- return util.init(driver)
- .get('wxpage://' + util.getDeviceHost() +'/image.js')
- .waitForElementByXPath('//div/text[1]',util.getGETActionWaitTimeMills(),1000)
- });
-
- after(function () {
- return util.quit(driver);
- })
-
-
- it('#1 download image', () => {
- return driver
- .sleep(5000)
- .elementByXPath('//div/text')
- .text()
- .then((text)=>{
- if(text == '-1,-1') {
- return;
- }
- assert.equal(text, '360,388')
- })
- })
-});
-
-
[2/5] incubator-weex git commit: * [android] update testcase
Posted by so...@apache.org.
* [android] update testcase
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/26ad7abe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/26ad7abe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/26ad7abe
Branch: refs/heads/0.11-dev
Commit: 26ad7abe7a25e4f53bc863ea15515f2d754a0a30
Parents: 5a285f0
Author: moxun.ljf <mo...@alibaba-inc.com>
Authored: Thu Mar 2 16:52:33 2017 +0800
Committer: moxun.ljf <mo...@alibaba-inc.com>
Committed: Thu Mar 2 16:52:33 2017 +0800
----------------------------------------------------------------------
test/pages/image.we | 19 +++++++++++++++
test/scripts/components/image.test.js | 39 ++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/26ad7abe/test/pages/image.we
----------------------------------------------------------------------
diff --git a/test/pages/image.we b/test/pages/image.we
new file mode 100644
index 0000000..8d21c7a
--- /dev/null
+++ b/test/pages/image.we
@@ -0,0 +1,19 @@
+<template>
+ <div>
+ <img style="width: 500;height: 500;" src="https://gw.alicdn.com/tps/TB1bEMYKXXXXXaLaXXXXXXXXXXX-360-388.png" onload="onload"></img>
+ <text style="font-size:30">{{size}}</text>
+ </div>
+</template>
+<script>
+ module.exports = {
+ data : {
+ size:"-1,-1"
+ },
+ methods : {
+ onload : function(e) {
+ nativeLog(JSON.stringify(e))
+ this.size = e.size.naturalWidth + ',' + e.size.naturalHeight;
+ }
+ }
+ }
+</script>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/26ad7abe/test/scripts/components/image.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/image.test.js b/test/scripts/components/image.test.js
new file mode 100644
index 0000000..8030511
--- /dev/null
+++ b/test/scripts/components/image.test.js
@@ -0,0 +1,39 @@
+'use strict';
+
+var _ = require('macaca-utils');
+var assert = require('chai').assert
+var wd = require('weex-wd')
+var path = require('path');
+var os = require('os');
+var util = require("../util.js");
+
+describe('image onload', function () {
+ this.timeout(util.getTimeoutMills());
+ var driver = util.createDriver(wd);
+
+ before(function () {
+ return util.init(driver)
+ .get('wxpage://' + util.getDeviceHost() +'/image.js')
+ .waitForElementByXPath('//div/text[1]',util.getGETActionWaitTimeMills(),1000)
+ });
+
+ after(function () {
+ return util.quit(driver);
+ })
+
+
+ it('#1 download image', () => {
+ return driver
+ .sleep(5000)
+ .elementByXPath('//div/text')
+ .text()
+ .then((text)=>{
+ if(text == '-1,-1') {
+ return;
+ }
+ assert.equal(text, '360,388')
+ })
+ })
+});
+
+