You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/07/28 04:17:51 UTC
[1/5] incubator-weex git commit: * [ios] fix image load event not
fired when image download failed
Repository: incubator-weex
Updated Branches:
refs/heads/0.16-dev a54bcb91d -> e766955fa
* [ios] fix image load event not fired when image download failed
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/29f5ecb7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/29f5ecb7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/29f5ecb7
Branch: refs/heads/0.16-dev
Commit: 29f5ecb7a215116213b0d3c0217d6c509ac68890
Parents: e01d0e7
Author: acton393 <zh...@gmail.com>
Authored: Wed Jul 26 18:04:32 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Jul 26 18:04:32 2017 +0800
----------------------------------------------------------------------
.../WeexSDK/Sources/Component/WXImageComponent.m | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/29f5ecb7/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index b0cd45e..7faec0a 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -317,6 +317,16 @@ static dispatch_queue_t WXImageUpdateQueue;
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(self) strongSelf = weakSelf;
+ if (strongSelf.imageLoadEvent) {
+ NSMutableDictionary *sizeDict = [NSMutableDictionary new];
+ sizeDict[@"naturalWidth"] = @0;
+ sizeDict[@"naturalHeight"] = @0;
+ if (!error) {
+ sizeDict[@"naturalWidth"] = @(image.size.width * image.scale);
+ sizeDict[@"naturalHeight"] = @(image.size.height * image.scale);
+ }
+ [strongSelf fireEvent:@"load" params:@{ @"success": error? @false : @true,@"size":sizeDict}];
+ }
if (error) {
downloadFailedBlock(imageSrc, error);
[strongSelf readyToRender];
@@ -336,13 +346,6 @@ static dispatch_queue_t WXImageUpdateQueue;
strongSelf->_image = image;
[strongSelf setNeedsDisplay];
}
-
- if (strongSelf.imageLoadEvent) {
- NSMutableDictionary *sizeDict = [NSMutableDictionary new];
- sizeDict[@"naturalWidth"] = @(image.size.width * image.scale);
- sizeDict[@"naturalHeight"] = @(image.size.height * image.scale);
- [strongSelf fireEvent:@"load" params:@{ @"success": error? @false : @true,@"size":sizeDict}];
- }
});
}];
});
[3/5] incubator-weex git commit: * [ios] support save image to photo
album
Posted by ac...@apache.org.
* [ios] support save image to photo album
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/6cdc31f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/6cdc31f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/6cdc31f0
Branch: refs/heads/0.16-dev
Commit: 6cdc31f07ca8ac2887a6e4a33bf3e02de22dd59a
Parents: e4c466b
Author: acton393 <zh...@gmail.com>
Authored: Wed Jul 26 21:41:40 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Jul 26 21:41:40 2017 +0800
----------------------------------------------------------------------
.../Sources/Component/WXImageComponent.m | 53 ++++++++++++++++++++
1 file changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/6cdc31f0/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 7faec0a..b5d2081 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -61,6 +61,8 @@ static dispatch_queue_t WXImageUpdateQueue;
@implementation WXImageComponent
+WX_EXPORT_METHOD(@selector(save:))
+
- (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance
{
if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) {
@@ -118,6 +120,57 @@ static dispatch_queue_t WXImageUpdateQueue;
}
}
+- (void)save:(WXCallback)resultCallback
+{
+ NSDictionary *info = [NSBundle mainBundle].infoDictionary;
+ if(!info[@"NSPhotoLibraryUsageDescription"]) {
+ if (resultCallback) {
+ resultCallback(@{
+ @"success" : @(false),
+ @"errorDesc": @"This maybe crash above iOS 10 because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data."
+ });
+ }
+ if (WX_SYS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) {
+ // if the iOS version is above 10.0, this operation will skip
+ return;
+ }
+ }
+ if (![self isViewLoaded]) {
+ if (resultCallback) {
+ resultCallback(@{@"success": @(false),
+ @"errorDesc":@"the image is not ready"});
+ }
+ return;
+ }
+ UIImageView * imageView = (UIImageView*)self.view;
+ if (!resultCallback) {
+ // there is no need to callback any result;
+ UIImageWriteToSavedPhotosAlbum(imageView.image, nil, nil, NULL);
+ }else {
+ UIImageWriteToSavedPhotosAlbum(imageView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), (void*)CFBridgingRetain(resultCallback));
+ }
+}
+
+// the callback for PhotoAlbum.
+- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
+{
+ if (!contextInfo) {
+ return;
+ }
+ NSMutableDictionary * callbackResult = [NSMutableDictionary new];
+ BOOL success = false;
+ if (!error) {
+ success = true;
+ } else {
+ [callbackResult setObject:[error description] forKey:@"errorDesc"];
+ }
+ if (contextInfo) {
+ [callbackResult setObject:@(success) forKey:@"success"];
+ ((__bridge WXCallback)contextInfo)(callbackResult);
+ CFRelease(contextInfo);
+ }
+}
+
- (UIView *)loadView
{
return [[WXImageView alloc] init];
[4/5] incubator-weex git commit: Merge branch
'ios-feature-0.16-image-save' of https://github.com/acton393/incubator-weex;
branch '0.16-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex
into ios-feature-0.16-image-save
Posted by ac...@apache.org.
Merge branch 'ios-feature-0.16-image-save' of https://github.com/acton393/incubator-weex; branch '0.16-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into ios-feature-0.16-image-save
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/71277cd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/71277cd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/71277cd7
Branch: refs/heads/0.16-dev
Commit: 71277cd7bfdb300d52cd582d58d4e39cf965c6e2
Parents: 6cdc31f a54bcb9
Author: acton393 <zh...@gmail.com>
Authored: Thu Jul 27 14:29:18 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jul 27 14:29:18 2017 +0800
----------------------------------------------------------------------
WeexSDK.podspec | 2 +-
ios/playground/Podfile | 2 +-
ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m | 5 +++--
ios/sdk/WeexSDK/Sources/Bridge/WXModuleMethod.h | 2 ++
ios/sdk/WeexSDK/Sources/Bridge/WXModuleMethod.m | 11 ++++++++---
ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m | 13 ++++++++-----
ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m | 2 ++
ios/sdk/WeexSDK/Sources/Protocol/WXValidateProtocol.h | 4 ++--
ios/sdk/WeexSDK/Sources/Utility/WXDefine.h | 2 +-
9 files changed, 28 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
[2/5] incubator-weex git commit: * [ios] update image onload event
failed case
Posted by ac...@apache.org.
* [ios] update image onload event failed case
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e4c466b7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e4c466b7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e4c466b7
Branch: refs/heads/0.16-dev
Commit: e4c466b7d6a797eb72cbbfa646650b79280e458a
Parents: 29f5ecb
Author: acton393 <zh...@gmail.com>
Authored: Wed Jul 26 18:36:17 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Jul 26 18:36:17 2017 +0800
----------------------------------------------------------------------
test/pages/image-onload.vue | 14 ++++++++++++--
test/scripts/components/image-onload.test.js | 10 ++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e4c466b7/test/pages/image-onload.vue
----------------------------------------------------------------------
diff --git a/test/pages/image-onload.vue b/test/pages/image-onload.vue
index 0c0b309..7d0167c 100644
--- a/test/pages/image-onload.vue
+++ b/test/pages/image-onload.vue
@@ -1,20 +1,30 @@
<template>
- <scroller>
+ <scroller style='alignItems:center'>
<image style="width: 500;height: 500;" src="https://gw.alicdn.com/tps/TB1bEMYKXXXXXaLaXXXXXXXXXXX-360-388.png" @load="onload"></image>
<text test-id='imgSize' style="font-size:30">{{size}}</text>
+ <image style="width: 300;height: 300;border-width:2px;" src="https://cn.vuejs.org/images/logo.png1" @load="onloadFailed"></image>
+ <text test-id='download' style="font-size:30">{{download}}</text>
</scroller>
</template>
<script>
module.exports = {
data : function(){
return {
- size:"-1,-1"
+ size:"-1,-1",
+ download:'success'
}
},
methods : {
onload : function(e) {
nativeLog(JSON.stringify(e))
this.size = e.size.naturalWidth + ',' + e.size.naturalHeight;
+ },
+ onloadFailed:function(e) {
+ if (e.success){
+ this.download = 'success';
+ }else {
+ this.download ='failed';
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e4c466b7/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 c3a7570..7c0e6d8 100644
--- a/test/scripts/components/image-onload.test.js
+++ b/test/scripts/components/image-onload.test.js
@@ -51,6 +51,16 @@ describe('image onload @ignore-ios', function () {
}
assert.equal(text, '360,388')
})
+ });
+
+ it('#2 test download image failed event', () => {
+ return driver
+ .sleep(5000)
+ .elementById('download')
+ .text()
+ .then((text)=>{
+ assert.equal(text, 'failed')
+ })
})
});
[5/5] incubator-weex git commit: * [ios] add error detail for image
load event when image load failed
Posted by ac...@apache.org.
* [ios] add error detail for image load event when image load failed
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e766955f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e766955f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e766955f
Branch: refs/heads/0.16-dev
Commit: e766955fafcfec8825a0733f1a105940bb3e3d0f
Parents: 71277cd
Author: acton393 <zh...@gmail.com>
Authored: Fri Jul 28 10:58:52 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Jul 28 10:58:52 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e766955f/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index b5d2081..c880a60 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -377,6 +377,8 @@ WX_EXPORT_METHOD(@selector(save:))
if (!error) {
sizeDict[@"naturalWidth"] = @(image.size.width * image.scale);
sizeDict[@"naturalHeight"] = @(image.size.height * image.scale);
+ } else {
+ [sizeDict setObject:[error description]?:@"" forKey:@"errorDesc"];
}
[strongSelf fireEvent:@"load" params:@{ @"success": error? @false : @true,@"size":sizeDict}];
}