...
|
...
|
@@ -164,8 +164,7 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week |
|
|
}
|
|
|
|
|
|
// Second check the disk cache...
|
|
|
UIImage *diskImage = [UIImage decodedImageWithImage:SDScaledImageForPath(key, [NSData dataWithContentsOfFile:[self cachePathForKey:key]])];
|
|
|
|
|
|
UIImage *diskImage = [self diskImageForKey:key];
|
|
|
if (diskImage)
|
|
|
{
|
|
|
CGFloat cost = diskImage.size.height * diskImage.size.width * diskImage.scale;
|
...
|
...
|
@@ -175,6 +174,27 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week |
|
|
return diskImage;
|
|
|
}
|
|
|
|
|
|
- (UIImage *)diskImageForKey:(NSString *)key
|
|
|
{
|
|
|
NSString *path = [self cachePathForKey:key];
|
|
|
NSData *data = [NSData dataWithContentsOfFile:path];
|
|
|
if (data)
|
|
|
{
|
|
|
UIImage *image = [[UIImage alloc] initWithData:data];
|
|
|
UIImage *scaledImage = [self scaledImageForKey:key image:image];
|
|
|
return [UIImage decodedImageWithImage:scaledImage];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return nil;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image
|
|
|
{
|
|
|
return SDScaledImageForKey(key, image);
|
|
|
}
|
|
|
|
|
|
- (void)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock
|
|
|
{
|
|
|
if (!doneBlock) return;
|
...
|
...
|
@@ -197,8 +217,7 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week |
|
|
{
|
|
|
@autoreleasepool
|
|
|
{
|
|
|
UIImage *diskImage = [UIImage decodedImageWithImage:SDScaledImageForPath(key, [NSData dataWithContentsOfFile:[self cachePathForKey:key]])];
|
|
|
|
|
|
UIImage *diskImage = [self diskImageForKey:key];
|
|
|
if (diskImage)
|
|
|
{
|
|
|
CGFloat cost = diskImage.size.height * diskImage.size.width * diskImage.scale;
|
...
|
...
|
|