You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2018/11/22 08:09:53 UTC
[incubator-weex] branch master updated: [iOS]sometime image size is
so big when loading image (#1795)
This is an automated email from the ASF dual-hosted git repository.
cxfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new b335bd6 [iOS]sometime image size is so big when loading image (#1795)
b335bd6 is described below
commit b335bd6844027c7b17bb6522d2aaee6524100c5a
Author: jianhan-he <41...@users.noreply.github.com>
AuthorDate: Thu Nov 22 16:09:49 2018 +0800
[iOS]sometime image size is so big when loading image (#1795)
---
ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 0c98098..ab4f63c 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -56,6 +56,7 @@ static dispatch_queue_t WXImageUpdateQueue;
NSString * _imageSrc;
pthread_mutex_t _imageSrcMutex;
pthread_mutexattr_t _propertMutexAttr;
+ BOOL _shouldUpdateImage;
}
@property (atomic, strong) NSString *placeholdSrc;
@@ -80,6 +81,7 @@ 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]) {
+ _shouldUpdateImage = NO;
_async = YES;
if (!WXImageUpdateQueue) {
WXImageUpdateQueue = dispatch_queue_create("com.taobao.weex.ImageUpdateQueue", DISPATCH_QUEUE_SERIAL);
@@ -382,8 +384,21 @@ WX_EXPORT_METHOD(@selector(save:))
[self updateImage];
}
+- (void)layoutDidFinish
+{
+ [super layoutDidFinish];
+ if (_shouldUpdateImage) {
+ [self updateImage];
+ _shouldUpdateImage = NO;
+ }
+}
+
- (void)updateImage
{
+ if (CGSizeEqualToSize(_view.frame.size, CGSizeZero)) {
+ _shouldUpdateImage = YES;
+ return;
+ }
__weak typeof(self) weakSelf = self;
if (_downloadImageWithURL && [[self imageLoader] respondsToSelector:@selector(setImageViewWithURL:url:placeholderImage:options:progress:completed:)]) {
NSString *newURL = nil;
@@ -600,6 +615,7 @@ WX_EXPORT_METHOD(@selector(save:))
if ([[self imageLoader] respondsToSelector:@selector(cancelCurrentImageLoad:)]) {
[[self imageLoader] cancelCurrentImageLoad:(UIImageView*)_view];
}
+ _shouldUpdateImage = NO;
[_imageOperation cancel];
_imageOperation = nil;
[_placeholderOperation cancel];