Merge pull request #700 from herrernst/master
Save image in cache before calling completion block
This commit is contained in:
commit
8fe72023dc
|
@ -162,24 +162,24 @@
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
|
UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
|
||||||
|
|
||||||
dispatch_main_sync_safe(^{
|
|
||||||
completedBlock(transformedImage, nil, SDImageCacheTypeNone, finished);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (transformedImage && finished) {
|
if (transformedImage && finished) {
|
||||||
BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage];
|
BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage];
|
||||||
[self.imageCache storeImage:transformedImage recalculateFromImage:imageWasTransformed imageData:data forKey:key toDisk:cacheOnDisk];
|
[self.imageCache storeImage:transformedImage recalculateFromImage:imageWasTransformed imageData:data forKey:key toDisk:cacheOnDisk];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatch_main_sync_safe(^{
|
||||||
|
completedBlock(transformedImage, nil, SDImageCacheTypeNone, finished);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dispatch_main_sync_safe(^{
|
|
||||||
completedBlock(downloadedImage, nil, SDImageCacheTypeNone, finished);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (downloadedImage && finished) {
|
if (downloadedImage && finished) {
|
||||||
[self.imageCache storeImage:downloadedImage recalculateFromImage:NO imageData:data forKey:key toDisk:cacheOnDisk];
|
[self.imageCache storeImage:downloadedImage recalculateFromImage:NO imageData:data forKey:key toDisk:cacheOnDisk];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatch_main_sync_safe(^{
|
||||||
|
completedBlock(downloadedImage, nil, SDImageCacheTypeNone, finished);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue