Skip to content

Commit

Permalink
Greatly improved how we grab and display show posters on the Subscrip…
Browse files Browse the repository at this point in the history
…tion screen (no longer requires model change).
  • Loading branch information
Matthew Price committed Mar 6, 2011
1 parent ab12f46 commit 376da14
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 218 deletions.
8 changes: 1 addition & 7 deletions Classes/CacheDelegate.m
Expand Up @@ -69,18 +69,12 @@ - (NSPersistentStoreCoordinator *) persistentStoreCoordinator
}
}

// Ignoring persistent versioning is bad. We should change this later...
NSMutableDictionary *options = [NSMutableDictionary dictionary];
[options setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption];
[options setObject:[NSNumber numberWithBool:YES] forKey:NSIgnorePersistentStoreVersioningOption];
// [options setObject:[NSNumber numberWithBool:YES] forKey:NSInferMappingModelAutomaticallyOption];

NSURL *url = [NSURL fileURLWithPath: [applicationSupportDirectory stringByAppendingPathComponent: @"Cache"]];
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: mom];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:url
options:options
options:nil
error:&error]){
[[NSApplication sharedApplication] presentError:error];
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
Expand Down
8 changes: 1 addition & 7 deletions Classes/PresetShowsDelegate.m
Expand Up @@ -69,18 +69,12 @@ - (NSPersistentStoreCoordinator *) persistentStoreCoordinator
}
}

// Ignoring persistent versioning is bad. We should change this later...
NSMutableDictionary *options = [NSMutableDictionary dictionary];
[options setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption];
[options setObject:[NSNumber numberWithBool:YES] forKey:NSIgnorePersistentStoreVersioningOption];
// [options setObject:[NSNumber numberWithBool:YES] forKey:NSInferMappingModelAutomaticallyOption];

NSURL *url = [NSURL fileURLWithPath: [applicationSupportDirectory stringByAppendingPathComponent: @"Preset Shows"]];
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: mom];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:url
options:options
options:nil
error:&error]){
[[NSApplication sharedApplication] presentError:error];
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
Expand Down
8 changes: 1 addition & 7 deletions Classes/SubscriptionsDelegate.m
Expand Up @@ -70,18 +70,12 @@ - (NSPersistentStoreCoordinator *) persistentStoreCoordinator
}
}

// Ignoring persistent versioning is bad. We should change this later...
NSMutableDictionary *options = [NSMutableDictionary dictionary];
[options setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption];
[options setObject:[NSNumber numberWithBool:YES] forKey:NSIgnorePersistentStoreVersioningOption];
// [options setObject:[NSNumber numberWithBool:YES] forKey:NSInferMappingModelAutomaticallyOption];

NSURL *url = [NSURL fileURLWithPath: [applicationSupportDirectory stringByAppendingPathComponent: @"Subscriptions"]];
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: mom];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType
configuration:nil
URL:url
options:options
options:nil
error:&error]){
[[NSApplication sharedApplication] presentError:error];
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
Expand Down
38 changes: 0 additions & 38 deletions Classes/TSCollectionView.m

This file was deleted.

13 changes: 13 additions & 0 deletions Classes/TVShowsPref.m
Expand Up @@ -15,12 +15,25 @@
#import "TVShowsPref.h"
#import "TSUserDefaults.h"
#import "AppInfoConstants.h"
#import "ValueTransformers.h"


@implementation TVShowsPref

@synthesize releaseNotesURL;

- init
{
if((self = [super init])) {
// Initialize any transformers we need to use in Interface Builder.
ShowPosterValueTransformer *trOne = [[[ShowPosterValueTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:trOne
forName:@"ShowPosterValueTransformer"];
}

return self;
}

- (void) didSelect
{
NSString *buildVersion = [[[NSBundle bundleWithIdentifier: TVShowsAppDomain] infoDictionary]
Expand Down
2 changes: 1 addition & 1 deletion Classes/TheTVDB.h
Expand Up @@ -27,6 +27,6 @@

+ (NSString *) getShowStatus:(NSString *)showName;
+ (NSImage *) getPosterForShow:(NSString *)showName withHeight:(float)height withWidth:(float)width;
+ (NSString *) getPosterPathForShow:(NSString *)showName;
- (NSImage *) getPosterForShow:(NSString *)showName withHeight:(float)height withWidth:(float)width;

@end
9 changes: 2 additions & 7 deletions Classes/TheTVDB.m
Expand Up @@ -195,16 +195,11 @@ + (NSImage *) getPosterForShow:(NSString *)showName withHeight:(float)height wit
}
}

+ (NSString *) getPosterPathForShow:(id)showName
- (NSImage *) getPosterForShow:(NSString *)showName withHeight:(float)height withWidth:(float)width
{
// Tell the app to download a poster (if needed) like normal...
[self getPosterForShow:showName withHeight:96 withWidth:66];

// But return the path to the poster instead of an NSImage.
return [[[self applicationCacheDirectory] stringByAppendingPathComponent:showName] stringByAppendingFormat:@".jpg"];
return [[TheTVDB class] getPosterForShow:showName withHeight:height withWidth:width];
}


- (void) dealloc
{
[serverTime release];
Expand Down
10 changes: 6 additions & 4 deletions Classes/TSCollectionView.h → Classes/ValueTransformers.h
Expand Up @@ -12,13 +12,15 @@
*
*/


#import <Cocoa/Cocoa.h>


@interface TSCollectionView : NSCollectionView
{

@interface ShowPosterValueTransformer : NSValueTransformer {

}

+ (Class) transformedValueClass;
+ (BOOL) allowsReverseTransformation;
- (id) transformedValue:(id)value;

@end
41 changes: 41 additions & 0 deletions Classes/ValueTransformers.m
@@ -0,0 +1,41 @@
/*
* This file is part of the TVShows 2 ("Phoenix") source code.
* http://github.com/mattprice/TVShows/
*
* TVShows is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* You should have received a copy of the GNU General Public License
* along with TVShows. If not, see <http://www.gnu.org/licenses/>.
*
*/

#import "ValueTransformers.h"
#import "TheTVDB.h"


@implementation ShowPosterValueTransformer

+ (Class) transformedValueClass;
{
return [NSImage class];
}

+ (BOOL) allowsReverseTransformation
{
return NO;
}

- (id) transformedValue:(id)value
{
// For some reason, we sometimes receive nil values.
// Those will crash the program if we aren't careful.
if (value == nil) return nil;

NSImage *showPoster = [[TheTVDB class] getPosterForShow:value withHeight:96 withWidth:66];
return showPoster;
}

@end
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions Models/Subscriptions.xcdatamodeld/.xccurrentversion

This file was deleted.

Binary file not shown.
Binary file not shown.

0 comments on commit 376da14

Please sign in to comment.