Changeset 1204
- Timestamp:
- 03/09/2010 05:11:28 PM (2 years ago)
- Location:
- trunk/SapphireFrappliance/MetaDataImporting
- Files:
-
- 2 modified
-
SapphirePosterChooser.h (modified) (2 diffs)
-
SapphirePosterChooser.m (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SapphireFrappliance/MetaDataImporting/SapphirePosterChooser.h
r1179 r1204 32 32 @interface SapphirePosterChooser : SapphireMediaMenuController <BRIconSourceProtocol, BRMenuListItemProvider, SapphireLayoutDelegate, SapphireChooser> { 33 33 BOOL displayed; /*!< @brief YES if currently displayed, NO otherwise*/ 34 NSMutableArray *posters; /*!< @brief The array of poster urls and after loaded, the NSImages*/ 35 NSMutableArray *posterLayers; /*!< @brief The image layers of posters*/ 36 NSMutableArray *posterData; /*!< @brief The data for the poster images*/ 34 NSMutableArray *posters; /*!< @brief The array of poster urls, NSImages, NSData, or BlurredImages*/ 37 35 NSString *fileName; /*!< @brief The movie filename*/ 38 36 NSString *movieTitle; /*!< @brief The title of the movie*/ … … 77 75 78 76 /*! 79 * @brief The list of posters to choose from80 *81 * @return The list of posters to choose from82 */83 - (NSArray *)posters;84 85 /*!86 * @brief Loads the posters from disk87 */88 - (void)loadPosters;89 90 /*!91 77 * @brief Sets the filename to display 92 78 * -
trunk/SapphireFrappliance/MetaDataImporting/SapphirePosterChooser.m
r1198 r1204 41 41 @interface SapphirePosterChooser () 42 42 - (BRBlurryImageLayer *)getPosterLayerForData:(NSData *)thePosterData; 43 - (void)loadPoster:(int)index; 44 - (void)reloadPosterWithData:(NSData *)data atIndex:(int)intIndex; 43 - (void)loadPosters; 44 - (void)loadPosterWithURL:(int)index; 45 - (void)reloadPosterWithDataAtIndex:(int)intIndex; 45 46 @end 46 47 … … 93 94 // [posterMarch setIconSource: nil]; //This throws an exception 94 95 [posters release]; 95 [posterLayers release];96 [posterData release];97 96 [fileName release]; 98 97 [movieTitle release]; … … 157 156 #pragma mark List of posters 158 157 158 - (void)freePosterMarch 159 { 160 [posterMarch release]; 161 posterMarch = nil; 162 } 163 159 164 - (void)setPosters:(NSArray *)posterList 160 165 { 161 166 posters = [posterList mutableCopy]; 162 167 if([posters count] > 5) 163 { 164 [posterMarch release]; 165 posterMarch = nil; 168 [self freePosterMarch]; 169 else 170 { 171 [posterMarch setIconSource: self]; 166 172 } 167 173 [self loadPosters]; 168 [posterMarch setIconSource: self];169 174 [[self list] setDatasource:self]; 170 175 } … … 174 179 posters = [posterList retain]; 175 180 176 [posterMarch release]; 177 posterMarch = nil; 178 179 [[self list] setDatasource: self]; 181 [self freePosterMarch]; 182 [[self list] setDatasource:self]; 180 183 } 181 184 … … 188 191 { 189 192 int i, count = [posters count]; 190 posterLayers = [posters mutableCopy];191 posterData = [[NSMutableArray alloc] initWithCapacity:[posters count]];192 NSNull *nsnull = [NSNull null];193 193 for(i=0; i<count; i++) 194 [posterData addObject:nsnull]; 195 for(i=0; i<count; i++) 196 [self loadPoster:i]; 194 [self loadPosterWithURL:i]; 197 195 [posterMarch reload]; 198 196 [SapphireFrontRowCompat renderScene:[self scene]]; … … 204 202 * @param The index of the poster to load 205 203 */ 206 - (void)loadPoster :(int)index;204 - (void)loadPosterWithURL:(int)index; 207 205 { 208 206 NSString *posterURL = [posters objectAtIndex:index]; 209 [posterLayers replaceObjectAtIndex:index withObject:[self getPosterLayerForData:nil]];210 207 [[SapphireApplianceController urlLoader] loadDataURL:posterURL withTarget:self selector:@selector(gotPosterData:atIndex:) object:[NSNumber numberWithInt:index] withPriority:YES]; 211 208 } … … 213 210 - (void)gotPosterData:(NSData *)data atIndex:(NSNumber *)index; 214 211 { 215 if(displayed) 216 [self reloadPosterWithData:data atIndex:[index intValue]]; 217 else if(data != nil) 218 [posterData replaceObjectAtIndex:[index intValue] withObject:data]; 219 else 220 [posterData replaceObjectAtIndex:[index intValue] withObject:[NSData data]]; 221 } 222 223 - (void)reloadPosterWithData:(NSData *)data atIndex:(int)intIndex; 224 { 225 [posterLayers replaceObjectAtIndex:intIndex withObject:[self getPosterLayerForData:data]]; 226 NSImage *image = [[NSImage alloc] initWithData:data]; 227 if(image == nil) 228 image = [errorNSImage retain]; 229 [posters replaceObjectAtIndex:intIndex withObject:image]; 230 [image release]; 212 if(data != nil) 213 [posters replaceObjectAtIndex:[index intValue] withObject:data]; 214 else 215 [posters replaceObjectAtIndex:[index intValue] withObject:[NSData data]]; 216 if(displayed && posterMarch) 217 [self reloadPosterWithDataAtIndex:[index intValue]]; 218 } 219 220 - (void)reloadPosterWithDataAtIndex:(int)intIndex; 221 { 222 NSData *data = [posters objectAtIndex:intIndex]; 223 [posters replaceObjectAtIndex:intIndex withObject:[self getPosterLayerForData:data]]; 231 224 [posterMarch _updateIcons]; 232 225 if([self getSelection] == intIndex) … … 367 360 - (long)iconCount 368 361 { 369 return [poster Layers count];362 return [posters count]; 370 363 } 371 364 372 365 - (NSDictionary *)iconInfoAtIndex:(long)index 373 366 { 374 return [NSDictionary dictionaryWithObject:[posterLayers objectAtIndex:index] forKey:@"icon"]; 367 id poster = [posters objectAtIndex:index]; 368 if([poster isKindOfClass:[NSString class]] || [poster isKindOfClass:[NSData class]]) 369 poster = defaultImage; 370 return [NSDictionary dictionaryWithObject:poster forKey:@"icon"]; 375 371 } 376 372 377 373 - (id)iconAtIndex:(long)index 378 374 { 379 if ( index >= [poster Layers count] )375 if ( index >= [posters count] ) 380 376 return nil; 381 377 382 return [poster Layers objectAtIndex:index];378 return [posters objectAtIndex:index]; 383 379 } 384 380 … … 410 406 id poster = [posters objectAtIndex:row]; 411 407 412 if( ![poster isKindOfClass:[NSStringclass]])408 if([poster isKindOfClass:[NSImage class]]) 413 409 [asset setImage:poster]; 410 else if([poster isKindOfClass:[NSData class]]) 411 { 412 NSImage *image = [[NSImage alloc] initWithData:poster]; 413 if(image) 414 { 415 [asset setImage:image]; 416 [image release]; 417 } 418 else 419 [asset setImage:errorNSImage]; 420 } 414 421 else 415 422 [asset setImage:defaultNSImage]; … … 555 562 [super wasPushed]; 556 563 displayed = YES; 557 int i, count = [posterData count]; 558 for(i=0; i<count; i++) 559 { 560 id obj = [posterData objectAtIndex:i]; 561 if([obj isKindOfClass:[NSData class]]) 562 [self reloadPosterWithData:obj atIndex:i]; 564 if(posterMarch) 565 { 566 int i, count = [posters count]; 567 for(i=0; i<count; i++) 568 { 569 id obj = [posters objectAtIndex:i]; 570 if([obj isKindOfClass:[NSData class]]) 571 [self reloadPosterWithDataAtIndex:i]; 572 } 563 573 } 564 574 }
