Permalink
Browse files

fixing Examples, creating more examples and putting them in easy to a…

…ccess group
  • Loading branch information...
1 parent 40bc039 commit d99be79119fc90881eb5a7ad15a8c4050c8ffee4 @tomcool420 committed Jul 13, 2011
@@ -6,7 +6,7 @@
// Copyright 2009 Thomas Cool. All rights reserved.
//
-#import <Backrow/Backrow.h>
+#import "../Backrow/AppleTV.h"
@interface SMFGridController : BRController {
@@ -6,8 +6,8 @@
//
#import "SMFBookcaseDelegateAndDatasourceExample.h"
-#import <SMFramework/SMFramework.h>
-
+#import "SMFramework.h"
+#import "BRMediaShelfView_SMF.h"
#define DEFAULT_IMAGES_PATH @"/System/Library/PrivateFrameworks/AppleTV.framework/DefaultFlowerPhotos/"
//storeRentalPlaceholderImage is part of the AppleTV headers, so it will be available at runtime
@@ -47,6 +47,7 @@ - (BRPhotoDataStoreProvider *)bookcaseController:(SMFBookcaseController *)bookca
//optional
- (BRImage *)headerIconForBookcaseController:(SMFBookcaseController *)bookcaseController {
return nil; //should be an image roughly 120 wide x 60 high
+
}
- (NSString *)bookcaseController:(SMFBookcaseController *)bookcaseController titleForShelfAtIndex:(NSInteger)index {
@@ -73,23 +74,23 @@ - (NSString *)bookcaseController:(SMFBookcaseController *)bookcaseController tit
#pragma mark -
#pragma mark SMFBookcaseControllerDelegate Methods
--(BOOL)bookcaseController:(SMFBookcaseController *)bookcaseController allowSelectionForShelf:(BRMediaShelfControl *)shelfControl atIndex:(NSInteger)index {
+
+-(BOOL)bookcaseController:(SMFBookcaseController *)bookcaseController allowSelectionForShelf:(BRMediaShelfView *)shelfControl atIndex:(NSInteger)index {
BOOL allow = YES;
if (index == 0) {
allow = NO; //no selections in the topmost shelf
}
return allow;
}
-
//optional
--(void)bookcaseController:(SMFBookcaseController *)bookcaseController selectionWillOccurInShelf:(BRMediaShelfControl *)shelfControl atIndex:(NSInteger)index {
+-(void)bookcaseController:(SMFBookcaseController *)bookcaseController selectionWillOccurInShelf:(BRMediaShelfView *)shelfControl atIndex:(NSInteger)index {
//will only get executed if the selection was allowed
NSInteger indexOfItemSelected = [shelfControl focusedIndex];
NSLog(@"selection for bookcase: [%@] in shelf [%@] at index [%d] at item [%d] is about to occur", bookcaseController, shelfControl, index, indexOfItemSelected);
}
--(void)bookcaseController:(SMFBookcaseController *)bookcaseController selectionDidOccurInShelf:(BRMediaShelfControl *)shelfControl atIndex:(NSInteger)index {
+-(void)bookcaseController:(SMFBookcaseController *)bookcaseController selectionDidOccurInShelf:(BRMediaShelfView *)shelfControl atIndex:(NSInteger)index {
//will only get executed if the selection was allowed
NSInteger indexOfItemSelected = [shelfControl focusedIndex];
View
@@ -0,0 +1,15 @@
+//
+// SMFExamples.h
+// SMFramework
+//
+// Created by Thomas Cool on 7/13/11.
+// Copyright 2011 tomcool.org. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "SMFramework.h"
+@interface SMFExamples : NSObject{
+
+}
++(SMFExamples *)examples;
+@end
View
@@ -0,0 +1,24 @@
+//
+// SMFExamples.m
+// SMFramework
+//
+// Created by Thomas Cool on 7/13/11.
+// Copyright 2011 tomcool.org. All rights reserved.
+//
+
+#import "SMFExamples.h"
+#import "SMFBookcaseController.h"
+#import "SMFBookcaseDelegateAndDatasourceExample.h"
+@implementation SMFExamples
+
+SYNTHESIZE_SINGLETON_FOR_CLASS(SMFExamples, examples)
+-(SMFBookcaseController *)bookcase
+{
+ SMFBookcaseController *c = [[SMFBookcaseController alloc]init ];
+ SMFBookcaseDelegateAndDatasourceExample *d = [[SMFBookcaseDelegateAndDatasourceExample alloc] init];
+ [c setDelegate:d];
+ [c setDatasource:d];
+ [d autorelease];
+ return [c autorelease];
+}
+@end
@@ -0,0 +1,21 @@
+//
+// SMFMoviePreviewDelegateAndDatasourceExample.h
+// SMFramework
+//
+// Created by Thomas Cool on 7/13/11.
+// Copyright 2011 tomcool.org. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "SMFMoviePreviewDelegateDatasource.h"
+#import "BackRow/AppleTV.h"
+@interface SMFMoviePreviewDelegateAndDatasourceExample : NSObject<SMFMoviePreviewControllerDelegate,SMFMoviePreviewControllerDatasource>
+-(NSString *)title;
+-(NSString *)subtitle;
+-(NSString *)summary;
+-(NSString *)posterPath;
+-(NSArray *)headers;
+-(NSArray *)columns;
+-(NSString *)rating;
+-(BRPhotoDataStoreProvider *)providerForShelf;
+@end
@@ -0,0 +1,139 @@
+//
+// SMFMoviePreviewDelegateAndDatasourceExample.m
+// SMFramework
+//
+// Created by Thomas Cool on 7/13/11.
+// Copyright 2011 tomcool.org. All rights reserved.
+//
+#import "SMFMoviePreviewController.h"
+#import "SMFMoviePreviewDelegateAndDatasourceExample.h"
+
+@implementation SMFMoviePreviewDelegateAndDatasourceExample
+#pragma mark datasource methods
+-(NSString *)title
+{
+ return @"Awesomeness";
+}
+-(NSString *)subtitle
+{
+ return @"An AwkwardTV Production";
+}
+-(NSString *)summary
+{
+ return @"Awesomeness, a history of development on the AppleTV. from tragedy to comedy, from whining to bitching, from compliments to insults: the History of the AppleTV in 5 acts. Complete with exta bashing, QQ and whining";
+}
+-(NSArray *)headers
+{
+ return [NSArray arrayWithObjects:@"Details",@"Actors",@"Director",@"Producers",nil];
+}
+-(NSArray *)columns
+{
+ NSArray *actors = [NSArray arrayWithObjects:@"|bile|",@"davilla",@"erica",@"mringwal",@"tomcool",nil];
+ NSArray *directors = [NSArray arrayWithObjects:@"macTijn",@" ",
+ [[[NSAttributedString alloc]initWithString:@"Art Director"
+ attributes:[[BRThemeInfo sharedTheme]metadataSummaryFieldAttributes]]autorelease],
+ @"Leddy",nil];
+ NSArray *producers = [NSArray arrayWithObjects:@"Alan Quatermain",@"gbooker",@"DHowett",nil];
+ BRImage *i = [[BRThemeInfo sharedTheme] hdBadge];
+ NSArray *details = [NSArray arrayWithObjects:
+ @"Action & Comedy",
+ @"Released: 2010",
+ [NSArray arrayWithObjects:
+ i,
+ [[[NSAttributedString alloc] initWithString:@" 2" attributes:[[BRThemeInfo sharedTheme]metadataTitleAttributes]]autorelease],
+ i,nil],
+ @"Run Time: Years",
+ [[SMFThemeInfo sharedTheme]fourPointFiveStars],
+ nil];
+ NSArray *objects = [NSArray arrayWithObjects:details,actors,directors,producers,nil];
+ return objects;
+}
+-(NSString *)rating
+{
+ return @"R";
+}
+-(BRImage *)coverArt
+{
+ return [BRImage imageWithPath:[self posterPath]];
+}
+-(NSString *)posterPath
+{
+ return [[NSBundle bundleForClass:[self class]]pathForResource:@"poster" ofType:@"jpg"];
+}
+-(BRPhotoDataStoreProvider *)providerForShelf
+{
+ NSSet *_set = [NSSet setWithObject:[BRMediaType photo]];
+ NSPredicate *_pred = [NSPredicate predicateWithFormat:@"mediaType == %@",[BRMediaType photo]];
+ BRDataStore *store = [[BRDataStore alloc] initWithEntityName:@"Hello" predicate:_pred mediaTypes:_set];
+ NSArray *assets = [SMFPhotoMethods mediaAssetsForPath:[[NSBundle bundleForClass:[self class]]pathForResource:@"Posters" ofType:@""]];
+ for (id a in assets) {
+ [store addObject:a];
+ }
+
+ //id dSPfCClass = NSClassFromString(@"BRPhotoDataStoreProvider");
+
+ id tcControlFactory = [BRPosterControlFactory factory];
+ id provider = [BRPhotoDataStoreProvider providerWithDataStore:store controlFactory:tcControlFactory];
+ [store release];
+ return provider;
+}
+-(NSArray *)buttons
+{
+ NSMutableArray *buttons = [[NSMutableArray alloc]init];
+ BRButtonControl* b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]previewActionImage]
+ subtitle:@"Preview"
+ badge:nil];
+ [buttons addObject:b];
+
+ b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]playActionImage]
+ subtitle:@"Play"
+ badge:nil];
+
+ [buttons addObject:b];
+
+ b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]queueActionImage]
+ subtitle:@"Queue"
+ badge:nil];
+
+ [buttons addObject:b];
+
+ b = [BRButtonControl actionButtonWithImage:[[BRThemeInfo sharedTheme]rateActionImage]
+ subtitle:@"More"
+ badge:nil];
+ [buttons addObject:b];
+ return [buttons autorelease];
+
+}
+#pragma mark delegate methods (examples)
+-(void)controller:(SMFMoviePreviewController *)c selectedControl:(BRControl *)ctrl {
+ NSLog(@"controller of type %@ selected", [ctrl class]);
+}
+//optional
+-(void)controller:(SMFMoviePreviewController *)c buttonSelectedAtIndex:(int)index {
+ NSLog(@"button at index %d selected", index);
+}
+-(void)controller:(SMFMoviePreviewController *)c switchedFocusTo:(BRControl *)newControl {
+ NSLog(@"controller of type %@ focused", [newControl class]);
+}
+-(void)controller:(SMFMoviePreviewController *)c shelfLastIndex:(long)index {
+ NSLog(@"last index of shelf was %d", index);
+}
+-(void)controllerSwitchToNext:(SMFMoviePreviewController *)c {
+ //flash arrow on, then off
+ [c switchNextArrowOn];
+ [c performSelector:@selector(switchNextArrowOff) withObject:nil afterDelay:0.7f];
+}
+-(void)controllerSwitchToPrevious:(SMFMoviePreviewController *)c {
+ //flash arrow on, then off
+ [c switchPreviousArrowOn];
+ [c performSelector:@selector(switchPreviousArrowOff) withObject:nil afterDelay:0.7f];
+}
+-(BOOL)controllerCanSwitchToNext:(SMFMoviePreviewController *)c {
+ return YES;
+}
+-(BOOL)controllerCanSwitchToPrevious:(SMFMoviePreviewController *)c {
+ return YES;
+}
+
+
+@end

0 comments on commit d99be79

Please sign in to comment.