|
|
@@ -338,73 +338,77 @@
|
|
|
|
|
|
- (void) photoCell:(PhotoPreviewCell *)cell loadImage:(NSDictionary *)item_json {
|
|
|
|
|
|
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
-
|
|
|
- NSString* img_url = [item_json valueForKey:@"s"];
|
|
|
- NSString* type = item_json[@"type"];
|
|
|
-
|
|
|
- NSString* file_name=[img_url lastPathComponent];
|
|
|
- NSData* img_data=nil;
|
|
|
-
|
|
|
- // 加载Image
|
|
|
- if([type isEqualToString:@"video"])
|
|
|
- {
|
|
|
- img_data = UIImagePNGRepresentation([UIImage imageNamed:@"play"]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if([item_json[@"is_localfile"] boolValue])
|
|
|
- img_data = [NSData dataWithContentsOfFile:img_url];
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
+
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
+
|
|
|
+ NSString* img_url = [item_json valueForKey:@"s"];
|
|
|
+ NSString* type = item_json[@"type"];
|
|
|
+
|
|
|
+ NSString* file_name=[img_url lastPathComponent];
|
|
|
+ NSData* img_data=nil;
|
|
|
+
|
|
|
+ // 加载Image
|
|
|
+ if([type isEqualToString:@"video"])
|
|
|
+ {
|
|
|
+ img_data = UIImagePNGRepresentation([UIImage imageNamed:@"play"]);
|
|
|
+ }
|
|
|
else
|
|
|
- img_data = [FileCache load_cached_img:file_name loadFrom:img_url];
|
|
|
- }
|
|
|
-
|
|
|
- // 设置Image
|
|
|
- if(img_data!=nil)
|
|
|
- {
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- UIImage * img =[UIImage imageWithData:img_data];
|
|
|
-
|
|
|
- [cell setPhoto:img];
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- NSData* downloadimg_data = nil;
|
|
|
- BOOL offline_mode = NO;
|
|
|
-#ifdef OFFLINE_MODE
|
|
|
- offline_mode = appDelegate.offline_mode;
|
|
|
-#endif
|
|
|
- if (!offline_mode) {
|
|
|
- downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
|
|
|
+ {
|
|
|
+ if([item_json[@"is_localfile"] boolValue])
|
|
|
+ img_data = [NSData dataWithContentsOfFile:img_url];
|
|
|
+ else
|
|
|
+ img_data = [FileCache load_cached_img:file_name loadFrom:img_url];
|
|
|
}
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(downloadimg_data!=nil)
|
|
|
- {
|
|
|
-
|
|
|
- [FileCache cache_img:downloadimg_data filename:file_name saveTo:img_url];
|
|
|
+
|
|
|
+ // 设置Image
|
|
|
+ if(img_data!=nil)
|
|
|
+ {
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ UIImage * img =[UIImage imageWithData:img_data];
|
|
|
|
|
|
- UIImage * img =[UIImage imageWithData:downloadimg_data];
|
|
|
[cell setPhoto:img];
|
|
|
-
|
|
|
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NSData* downloadimg_data = nil;
|
|
|
+ BOOL offline_mode = NO;
|
|
|
+#ifdef OFFLINE_MODE
|
|
|
+ offline_mode = appDelegate.offline_mode;
|
|
|
+#endif
|
|
|
+ if (!offline_mode) {
|
|
|
+ downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
|
|
- UIImage * img =[UIImage imageNamed:@"notfound_l"];
|
|
|
- [cell setPhoto:img];
|
|
|
-
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
+ if(downloadimg_data!=nil)
|
|
|
+ {
|
|
|
+
|
|
|
+ [FileCache cache_img:downloadimg_data filename:file_name saveTo:img_url];
|
|
|
+
|
|
|
+ UIImage * img =[UIImage imageWithData:downloadimg_data];
|
|
|
+ [cell setPhoto:img];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ UIImage * img =[UIImage imageNamed:@"notfound_l"];
|
|
|
+ [cell setPhoto:img];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|