diff --git a/Source/Details/ASPINRemoteImageDownloader.m b/Source/Details/ASPINRemoteImageDownloader.m index 601d0094..05107f8e 100644 --- a/Source/Details/ASPINRemoteImageDownloader.m +++ b/Source/Details/ASPINRemoteImageDownloader.m @@ -24,14 +24,20 @@ #import #import -#if __has_include () +#if __has_include () #define PIN_ANIMATED_AVAILABLE 1 -#import +#import #import #else #define PIN_ANIMATED_AVAILABLE 0 #endif +#if __has_include() +#define PIN_WEBP_AVAILABLE 1 +#else +#define PIN_WEBP_AVAILABLE 0 +#endif + #import #import #import @@ -42,35 +48,23 @@ @end -@interface PINAnimatedImage (ASPINRemoteImageDownloader) +@interface PINCachedAnimatedImage (ASPINRemoteImageDownloader) @end -@implementation PINAnimatedImage (ASPINRemoteImageDownloader) - -- (void)setCoverImageReadyCallback:(void (^)(UIImage * _Nonnull))coverImageReadyCallback -{ - self.infoCompletion = coverImageReadyCallback; -} - -- (void (^)(UIImage * _Nonnull))coverImageReadyCallback -{ - return self.infoCompletion; -} - -- (void)setPlaybackReadyCallback:(dispatch_block_t)playbackReadyCallback -{ - self.fileReady = playbackReadyCallback; -} - -- (dispatch_block_t)playbackReadyCallback -{ - return self.fileReady; -} +@implementation PINCachedAnimatedImage (ASPINRemoteImageDownloader) - (BOOL)isDataSupported:(NSData *)data { - return [data pin_isGIF]; + if ([data pin_isGIF]) { + return YES; + } +#if PIN_WEBP_AVAILABLE + else if ([data pin_isAnimatedWebP]) { + return YES; + } +#endif + return NO; } @end @@ -187,7 +181,7 @@ static ASPINRemoteImageDownloader *sharedDownloader = nil; #if PIN_ANIMATED_AVAILABLE - (nullable id )animatedImageWithData:(NSData *)animatedImageData { - return [[PINAnimatedImage alloc] initWithAnimatedImageData:animatedImageData]; + return [[PINCachedAnimatedImage alloc] initWithAnimatedImageData:animatedImageData]; } #endif @@ -365,6 +359,12 @@ static ASPINRemoteImageDownloader *sharedDownloader = nil; if ([data pin_isGIF]) { return data; } +#if PIN_WEBP_AVAILABLE + else if ([data pin_isAnimatedWebP]) { + return data; + } +#endif + #endif return nil; } diff --git a/examples/AnimatedGIF/ASAnimatedImage/ViewController.m b/examples/AnimatedGIF/ASAnimatedImage/ViewController.m index 90d88fbe..773ce936 100644 --- a/examples/AnimatedGIF/ASAnimatedImage/ViewController.m +++ b/examples/AnimatedGIF/ASAnimatedImage/ViewController.m @@ -32,7 +32,9 @@ // Do any additional setup after loading the view, typically from a nib. ASNetworkImageNode *imageNode = [[ASNetworkImageNode alloc] init]; - imageNode.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/originals/07/44/38/074438e7c75034df2dcf37ba1057803e.gif"]; +// imageNode.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/originals/07/44/38/074438e7c75034df2dcf37ba1057803e.gif"]; + imageNode.URL = [NSURL URLWithString:@"https://storage.googleapis.com/downloads.webmproject.org/webp/images/dancing_banana2.lossless.webp"]; +// imageNode.URL = [NSURL URLWithString:@"https://res.cloudinary.com/demo/image/upload/fl_awebp/bored_animation.webp"]; imageNode.frame = self.view.bounds; imageNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; imageNode.contentMode = UIViewContentModeScaleAspectFit; diff --git a/examples/AnimatedGIF/Podfile b/examples/AnimatedGIF/Podfile index 922ff50e..5d8e70ed 100644 --- a/examples/AnimatedGIF/Podfile +++ b/examples/AnimatedGIF/Podfile @@ -2,5 +2,8 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' target 'Sample' do pod 'Texture', :path => '../..' + # DO NOT COMMIT! + pod 'PINRemoteImage', :path => '~/Development/PINRemoteImage' + pod 'PINRemoteImage/WebP', :path => '~/Development/PINRemoteImage' end