mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Add a way to check if data is in a format supported by a class implementing ASAnimatedImageProtocol
This commit is contained in:
@@ -469,9 +469,13 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
|
||||
|
||||
// If the file may be an animated gif and then created an animated image.
|
||||
id<ASAnimatedImageProtocol> animatedImage = nil;
|
||||
if (_downloaderImplementsAnimatedImage && [_URL.pathExtension isEqualToString:@"gif"]) {
|
||||
if (_downloaderImplementsAnimatedImage) {
|
||||
NSData *data = [NSData dataWithContentsOfURL:_URL];
|
||||
animatedImage = [_downloader animatedImageWithData:data];
|
||||
|
||||
if ([animatedImage respondsToSelector:@selector(isDataSupported:)] && [animatedImage isDataSupported:data] == NO) {
|
||||
animatedImage = nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (animatedImage != nil) {
|
||||
|
||||
@@ -142,12 +142,21 @@ withDownloadIdentifier:(id)downloadIdentifier;
|
||||
|
||||
@protocol ASAnimatedImageProtocol <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
@abstract Should be called when the objects cover image is ready.
|
||||
@param coverImageReadyCallback a block which receives the cover image.
|
||||
*/
|
||||
@property (nonatomic, strong, readwrite) void (^coverImageReadyCallback)(UIImage *coverImage);
|
||||
|
||||
/**
|
||||
@abstract Returns whether the supplied data contains a supported animated image format.
|
||||
@param data the data to check if contains a supported animated image.
|
||||
*/
|
||||
- (BOOL)isDataSupported:(NSData *)data;
|
||||
|
||||
|
||||
@required
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
return self.fileReady;
|
||||
}
|
||||
|
||||
- (BOOL)isDataSupported:(NSData *)data
|
||||
{
|
||||
return [data pin_isGIF];
|
||||
}
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user