mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-11 08:50:24 +00:00
Fix not handling imageNode:didLoadImage: from ASNetworkImageNodeDelegate as optional
This commit is contained in:
parent
5d434d418f
commit
2c6e810e26
@ -44,9 +44,11 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
|
|||||||
CGFloat _currentImageQuality;
|
CGFloat _currentImageQuality;
|
||||||
CGFloat _renderedImageQuality;
|
CGFloat _renderedImageQuality;
|
||||||
|
|
||||||
|
// TODO: Move this to flags
|
||||||
BOOL _delegateSupportsDidStartFetchingData;
|
BOOL _delegateSupportsDidStartFetchingData;
|
||||||
BOOL _delegateSupportsDidFailWithError;
|
BOOL _delegateSupportsDidFailWithError;
|
||||||
BOOL _delegateSupportsImageNodeDidFinishDecoding;
|
BOOL _delegateSupportsDidFinishDecoding;
|
||||||
|
BOOL _delegateSupportsDidLoadImage;
|
||||||
|
|
||||||
BOOL _shouldRenderProgressImages;
|
BOOL _shouldRenderProgressImages;
|
||||||
|
|
||||||
@ -214,7 +216,8 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
|
|||||||
|
|
||||||
_delegateSupportsDidStartFetchingData = [delegate respondsToSelector:@selector(imageNodeDidStartFetchingData:)];
|
_delegateSupportsDidStartFetchingData = [delegate respondsToSelector:@selector(imageNodeDidStartFetchingData:)];
|
||||||
_delegateSupportsDidFailWithError = [delegate respondsToSelector:@selector(imageNode:didFailWithError:)];
|
_delegateSupportsDidFailWithError = [delegate respondsToSelector:@selector(imageNode:didFailWithError:)];
|
||||||
_delegateSupportsImageNodeDidFinishDecoding = [delegate respondsToSelector:@selector(imageNodeDidFinishDecoding:)];
|
_delegateSupportsDidFinishDecoding = [delegate respondsToSelector:@selector(imageNodeDidFinishDecoding:)];
|
||||||
|
_delegateSupportsDidLoadImage = [delegate respondsToSelector:@selector(imageNode:didLoadImage:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id<ASNetworkImageNodeDelegate>)delegate
|
- (id<ASNetworkImageNodeDelegate>)delegate
|
||||||
@ -494,7 +497,9 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
|
|||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
self.currentImageQuality = 1.0;
|
self.currentImageQuality = 1.0;
|
||||||
});
|
});
|
||||||
[_delegate imageNode:self didLoadImage:self.image];
|
if (_delegateSupportsDidLoadImage) {
|
||||||
|
[_delegate imageNode:self didLoadImage:self.image];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -529,7 +534,9 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
|
|||||||
strongSelf->_cacheUUID = nil;
|
strongSelf->_cacheUUID = nil;
|
||||||
|
|
||||||
if (imageContainer != nil) {
|
if (imageContainer != nil) {
|
||||||
[strongSelf->_delegate imageNode:strongSelf didLoadImage:strongSelf.image];
|
if (strongSelf->_delegateSupportsDidLoadImage) {
|
||||||
|
[strongSelf->_delegate imageNode:strongSelf didLoadImage:strongSelf.image];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (error && strongSelf->_delegateSupportsDidFailWithError) {
|
else if (error && strongSelf->_delegateSupportsDidFailWithError) {
|
||||||
[strongSelf->_delegate imageNode:strongSelf didFailWithError:error];
|
[strongSelf->_delegate imageNode:strongSelf didFailWithError:error];
|
||||||
@ -581,7 +588,7 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
|
|||||||
[super displayDidFinish];
|
[super displayDidFinish];
|
||||||
|
|
||||||
ASDN::MutexLocker l(_lock);
|
ASDN::MutexLocker l(_lock);
|
||||||
if (_delegateSupportsImageNodeDidFinishDecoding && self.layer.contents != nil) {
|
if (_delegateSupportsDidFinishDecoding && self.layer.contents != nil) {
|
||||||
/* We store the image quality in _currentImageQuality whenever _image is set. On the following displayDidFinish, we'll know that
|
/* We store the image quality in _currentImageQuality whenever _image is set. On the following displayDidFinish, we'll know that
|
||||||
_currentImageQuality is the quality of the image that has just finished rendering. In order for this to be accurate, we
|
_currentImageQuality is the quality of the image that has just finished rendering. In order for this to be accurate, we
|
||||||
need to be sure we are on main thread when we set _currentImageQuality. Otherwise, it is possible for _currentImageQuality
|
need to be sure we are on main thread when we set _currentImageQuality. Otherwise, it is possible for _currentImageQuality
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user