Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // NSData *cachedData = [[ASIDownloadCache sharedCache] cachedResponseDataForURL:imageURL];
- // UIImage *thumb;
- // if(cachedData){
- // thumb = [[UIImage imageWithData:cachedData] imageByScalingForSize:CGSizeMake(240.0f, 160.0f) withBackgroundColor:[UIColor whiteColor]];
- // thumb = [thumb roundedCornerImage:NOVELL_CELL_RADIUS];
- // self.mainImage = thumb;
- // [self setNeedsDisplay];
- // NSLog(@"image cached");
- // return;
- // }
- // __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:imageURL];
- // [request setUsername:[DefaultsManager getUsername]];
- // [request setPassword:[DefaultsManager getPassword]];
- // [request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
- // [request setCompletionBlock:^{
- // int statusCode = [request responseStatusCode];
- // if(statusCode != 404){
- // NSData *responseData = [request responseData];
- // UIImage *thumb = [[UIImage imageWithData:responseData] imageByScalingForSize:CGSizeMake(240.0f, 160.0f) withBackgroundColor:[UIColor whiteColor]];
- // thumb = [thumb roundedCornerImage:NOVELL_CELL_RADIUS];
- // self.mainImage = thumb;
- // [self setNeedsDisplay];
- // }else{
- // [[ASIDownloadCache sharedCache]removeCachedDataForRequest:request];
- // }
- // }];
- AFImageCache *image_cache = [[AFImageCache alloc] init];
- NSData *cachedData;
- [image_cache cacheImageData:cachedData forURL:imageURL cacheName:@"NovellInHand"];
- UIImage *thumb;
- if(cachedData){
- thumb = [[UIImage imageWithData:cachedData] imageByScalingForSize:CGSizeMake(240.0f, 160.0f) withBackgroundColor:[UIColor whiteColor]];
- thumb = [thumb roundedCornerImage:NOVELL_CELL_RADIUS];
- self.mainImage = thumb;
- [self setNeedsDisplay];
- NSLog(@"image cached");
- return;
- }
- [image_cache release];
- AFImageRequestOperation *image_request = [AFImageRequestOperation imageRequestOperationWithRequest:[NSURLRequest requestWithURL:imageURL]
- imageProcessingBlock:nil
- cacheName:@"NovellInHand"
- success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image){
- UIImage *thumb = [image imageByScalingForSize:CGSizeMake(240.0f, 160.0f) withBackgroundColor:[UIColor whiteColor]];
- thumb = [thumb roundedCornerImage:NOVELL_CELL_RADIUS];
- self.mainImage = thumb;
- [self setNeedsDisplay];
- }
- failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
- }];
Add Comment
Please, Sign In to add comment