Fix coding style

This commit is contained in:
Olivier Poitrey 2011-07-13 21:23:13 +02:00
parent 314837de7e
commit 4005884df5
4 changed files with 18 additions and 16 deletions

View File

@ -41,8 +41,8 @@ static SDImageCache *instance;
cacheInQueue.maxConcurrentOperationCount = 1;
cacheOutQueue = [[NSOperationQueue alloc] init];
cacheOutQueue.maxConcurrentOperationCount = 1;
#if !TARGET_OS_IPHONE
#else
#if TARGET_OS_IPHONE
// Subscribe to app events
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(clearMemory)
@ -54,7 +54,7 @@ static SDImageCache *instance;
name:UIApplicationWillTerminateNotification
object:nil];
#ifdef __IPHONE_4_0
#ifdef __IPHONE_4_0
UIDevice *device = [UIDevice currentDevice];
if ([device respondsToSelector:@selector(isMultitaskingSupported)] && device.multitaskingSupported)
{
@ -64,7 +64,7 @@ static SDImageCache *instance;
name:UIApplicationDidEnterBackgroundNotification
object:nil];
}
#endif
#endif
#endif
}
@ -126,12 +126,12 @@ static SDImageCache *instance;
UIImage *image = [[self imageFromKey:key fromDisk:YES] retain]; // be thread safe with no lock
if (image)
{
#if !TARGET_OS_IPHONE
#if TARGET_OS_IPHONE
[fileManager createFileAtPath:[self cachePathForKey:key] contents:UIImageJPEGRepresentation(image, (CGFloat)1.0) attributes:nil];
#else
NSArray* representations = [image representations];
NSData* jpegData = [NSBitmapImageRep representationOfImageRepsInArray: representations usingType: NSJPEGFileType properties:nil];
[fileManager createFileAtPath:[self cachePathForKey:key] contents:jpegData attributes:nil];
#else
[fileManager createFileAtPath:[self cachePathForKey:key] contents:UIImageJPEGRepresentation(image, (CGFloat)1.0) attributes:nil];
#endif
[image release];
}

View File

@ -20,7 +20,7 @@ extern NSString *const SDWebImageDownloadStopNotification;
id<SDWebImageDownloaderDelegate> delegate;
NSURLConnection *connection;
NSMutableData *imageData;
id userInfo;
id userInfo;
BOOL lowPriority;
}

View File

@ -22,13 +22,13 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot
+ (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)delegate
{
return [[self class] downloaderWithURL:url delegate:delegate userInfo:nil];
return [self downloaderWithURL:url delegate:delegate userInfo:nil];
}
+ (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)delegate userInfo:(id)userInfo
{
return [[self class] downloaderWithURL:url delegate:delegate userInfo:userInfo lowPriority:NO];
return [self downloaderWithURL:url delegate:delegate userInfo:userInfo lowPriority:NO];
}
+ (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)delegate userInfo:(id)userInfo lowPriority:(BOOL)lowPriority
@ -45,7 +45,7 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot
selector:NSSelectorFromString(@"stopActivity")
name:SDWebImageDownloadStopNotification object:nil];
}
SDWebImageDownloader *downloader = [[[SDWebImageDownloader alloc] init] autorelease];
downloader.url = url;
downloader.delegate = delegate;
@ -116,7 +116,7 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot
{
[delegate performSelector:@selector(imageDownloaderDidFinish:) withObject:self];
}
if ([delegate respondsToSelector:@selector(imageDownloader:didFinishWithImage:)])
{
UIImage *image = [[UIImage alloc] initWithData:imageData];

View File

@ -70,10 +70,10 @@ static SDWebImageManager *instance;
{
return;
}
// Check the on-disk cache async so we don't block the main thread
NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:delegate, @"delegate", url, @"url", [NSNumber numberWithBool:lowPriority], @"low_priority", nil];
[[SDImageCache sharedImageCache] queryDiskCacheForKey:[url absoluteString] delegate:self userInfo:info];
[[SDImageCache sharedImageCache] queryDiskCacheForKey:[url absoluteString] delegate:self userInfo:info];
}
- (void)cancelForDelegate:(id<SDWebImageManagerDelegate>)delegate
@ -125,11 +125,13 @@ static SDWebImageManager *instance;
downloader = [SDWebImageDownloader downloaderWithURL:url delegate:self userInfo:nil lowPriority:lowPriority];
[downloaderForURL setObject:downloader forKey:url];
}
// If we get a normal priority request, make sure to change type since downloader is shared
if (!lowPriority && downloader.lowPriority)
{
downloader.lowPriority = NO;
}
[delegates addObject:delegate];
[downloaders addObject:downloader];
}