iOS: fix quickly set image url caused image integrity error
This commit is contained in:
parent
f63da7a98a
commit
d62303baf0
@ -28,6 +28,7 @@
|
|||||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||||
|
|
||||||
#import <YYWebImage/YYWebImage.h>
|
#import <YYWebImage/YYWebImage.h>
|
||||||
|
#import <YYWebImage/_YYWebImageSetter.h>
|
||||||
|
|
||||||
@interface DoricImageView : YYAnimatedImageView
|
@interface DoricImageView : YYAnimatedImageView
|
||||||
@end
|
@end
|
||||||
@ -236,38 +237,42 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
__block BOOL async = NO;
|
__block BOOL async = NO;
|
||||||
view.doricLayout.undefined = YES;
|
view.doricLayout.undefined = YES;
|
||||||
#if __has_include(<YYWebImage/YYWebImage.h>)
|
#if __has_include(<YYWebImage/YYWebImage.h>)
|
||||||
[view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
|
dispatch_async([_YYWebImageSetter setterQueue], ^{
|
||||||
__strong typeof(_self) self = _self;
|
[view yy_cancelCurrentImageRequest];
|
||||||
if (self.placeHolderColor || self.errorColor) {
|
|
||||||
self.view.contentMode = self.contentMode;
|
[view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
|
||||||
}
|
__strong typeof(_self) self = _self;
|
||||||
self.view.doricLayout.undefined = NO;
|
if (self.placeHolderColor || self.errorColor) {
|
||||||
if (error) {
|
self.view.contentMode = self.contentMode;
|
||||||
[[self currentErrorImage] also:^(UIImage *it) {
|
|
||||||
self.view.image = it;
|
|
||||||
}];
|
|
||||||
if (self.loadCallbackId.length > 0) {
|
|
||||||
[self callJSResponse:self.loadCallbackId, nil];
|
|
||||||
}
|
}
|
||||||
} else if (image && stage == YYWebImageStageFinished) {
|
self.view.doricLayout.undefined = NO;
|
||||||
if (image.scale != self.imageScale) {
|
if (error) {
|
||||||
image = [YYImage imageWithCGImage:image.CGImage scale:self.imageScale orientation:image.imageOrientation];
|
[[self currentErrorImage] also:^(UIImage *it) {
|
||||||
self.view.image = image;
|
self.view.image = it;
|
||||||
}
|
}];
|
||||||
if (self.loadCallbackId.length > 0) {
|
if (self.loadCallbackId.length > 0) {
|
||||||
[self callJSResponse:self.loadCallbackId,
|
[self callJSResponse:self.loadCallbackId, nil];
|
||||||
@{@"width": @(image.size.width), @"height": @(image.size.height)},
|
}
|
||||||
nil];
|
} else if (image && stage == YYWebImageStageFinished) {
|
||||||
}
|
if (image.scale != self.imageScale) {
|
||||||
if (async) {
|
image = [YYImage imageWithCGImage:image.CGImage scale:self.imageScale orientation:image.imageOrientation];
|
||||||
DoricSuperNode *node = self.superNode;
|
self.view.image = image;
|
||||||
while (node.superNode != nil) {
|
}
|
||||||
node = node.superNode;
|
if (self.loadCallbackId.length > 0) {
|
||||||
|
[self callJSResponse:self.loadCallbackId,
|
||||||
|
@{@"width": @(image.size.width), @"height": @(image.size.height)},
|
||||||
|
nil];
|
||||||
|
}
|
||||||
|
if (async) {
|
||||||
|
DoricSuperNode *node = self.superNode;
|
||||||
|
while (node.superNode != nil) {
|
||||||
|
node = node.superNode;
|
||||||
|
}
|
||||||
|
[node requestLayout];
|
||||||
}
|
}
|
||||||
[node requestLayout];
|
|
||||||
}
|
}
|
||||||
}
|
}];
|
||||||
}];
|
});
|
||||||
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
#elif __has_include(<SDWebImage/SDWebImage.h>)
|
||||||
[view sd_setImageWithURL:[NSURL URLWithString:prop]
|
[view sd_setImageWithURL:[NSURL URLWithString:prop]
|
||||||
placeholderImage:[self currentPlaceHolderImage]
|
placeholderImage:[self currentPlaceHolderImage]
|
||||||
|
Reference in New Issue
Block a user