Last active
January 18, 2016 19:55
-
-
Save nloko/5a3bd6513fe20ed07ecd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.text = self.event.text; | |
__weak id wself = self; | |
NSString *imageUrl = self.event.imageUrl; | |
self.image = nil; | |
self.overlay.image = nil; | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
UIImage *image = [ImageCache sharedCache] get:imageUrl]; | |
if (!image) { | |
image = [[wself downloadImage:imageUrl] scaleWithWidth:cellWidth]; | |
[ImageCache sharedCache] put:image withKey:imageUrl]; | |
} | |
UIImage *blurredImage = [ImageCache blurredCache] get:imageUrl]; | |
if (!blurredImage) { | |
blurredImage = [image blurRect:overlayRect]; | |
[ImageCache blurredCache] put:blurredImage withKey:imageUrl]; | |
} | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
// skip if the cell’s event has changed | |
if (![imageUrl isEqualToString:wself.event.imageUrl]) { | |
return; | |
} | |
wself.overlay.image = blurredImage; | |
wself.image = image; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment