add BOOL if cache was used to load image

This is useful for animation - if function directly returns, there's no need to animate the new image
This commit is contained in:
Peter Steinberger 2011-09-12 17:36:20 +02:00
parent 2fbc30d137
commit 1ec54e2595
2 changed files with 4 additions and 4 deletions

View file

@ -39,6 +39,6 @@
placeholderImage:(UIImage *)placeholderImage
imageSize:(CGSize)imageSize
options:(AFImageRequestOptions)options
block:(void (^)(UIImage *image))block;
block:(void (^)(UIImage *image, BOOL cacheUsed))block;
@end

View file

@ -84,7 +84,7 @@ static NSString * const kUIImageViewImageRequestObjectKey = @"imageRequestOperat
placeholderImage:(UIImage *)placeholderImage
imageSize:(CGSize)imageSize
options:(AFImageRequestOptions)options
block:(void (^)(UIImage *image))block
block:(void (^)(UIImage *image, BOOL cacheUsed))block
{
if (!url) {
// stop loading image
@ -102,7 +102,7 @@ static NSString * const kUIImageViewImageRequestObjectKey = @"imageRequestOperat
self.image = cachedImage;
if (block) {
block(cachedImage);
block(cachedImage, YES);
}
} else {
self.image = placeholderImage;
@ -110,7 +110,7 @@ static NSString * const kUIImageViewImageRequestObjectKey = @"imageRequestOperat
self.imageRequestOperation = [AFImageRequestOperation operationWithRequest:request imageSize:imageSize options:options success:^(UIImage *image) {
if (self.imageRequestOperation && ![self.imageRequestOperation isCancelled]) {
if (block) {
block(image);
block(image, NO);
}
if ([[request URL] isEqual:[[self.imageRequestOperation request] URL]]) {