Merge pull request #1923 from garrettmoon/shareMemoryCache

Share ASDK's PINRemoteImage cache with default instance of PINRemoteI…
This commit is contained in:
Michael Schneider
2016-07-14 15:00:16 -07:00
committed by GitHub

View File

@@ -30,6 +30,7 @@
#import <PINCache/PINCache.h> #import <PINCache/PINCache.h>
#if PIN_ANIMATED_AVAILABLE #if PIN_ANIMATED_AVAILABLE
@interface ASPINRemoteImageDownloader () <PINRemoteImageManagerAlternateRepresentationProvider> @interface ASPINRemoteImageDownloader () <PINRemoteImageManagerAlternateRepresentationProvider>
@end @end
@@ -68,6 +69,19 @@
@end @end
#endif #endif
@interface ASPINRemoteImageManager : PINRemoteImageManager
@end
@implementation ASPINRemoteImageManager
//Share image cache with sharedImageManager image cache.
- (PINCache *)defaultImageCache
{
return [[PINRemoteImageManager sharedImageManager] cache];
}
@end
@implementation ASPINRemoteImageDownloader @implementation ASPINRemoteImageDownloader
+ (instancetype)sharedDownloader + (instancetype)sharedDownloader
@@ -82,7 +96,7 @@
- (PINRemoteImageManager *)sharedPINRemoteImageManager - (PINRemoteImageManager *)sharedPINRemoteImageManager
{ {
static PINRemoteImageManager *sharedPINRemoteImageManager = nil; static ASPINRemoteImageManager *sharedPINRemoteImageManager = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
@@ -102,9 +116,9 @@
userInfo:nil]; userInfo:nil];
@throw e; @throw e;
} }
sharedPINRemoteImageManager = [[PINRemoteImageManager alloc] initWithSessionConfiguration:nil alternativeRepresentationProvider:self]; sharedPINRemoteImageManager = [[ASPINRemoteImageManager alloc] initWithSessionConfiguration:nil alternativeRepresentationProvider:self];
#else #else
sharedPINRemoteImageManager = [[PINRemoteImageManager alloc] initWithSessionConfiguration:nil]; sharedPINRemoteImageManager = [[ASPINRemoteImageManager alloc] initWithSessionConfiguration:nil];
#endif #endif
}); });
return sharedPINRemoteImageManager; return sharedPINRemoteImageManager;