Skip to content

Commit

Permalink
fixed: #108 - tab switching can be slow
Browse files Browse the repository at this point in the history
fixed: grid remembers last position
+ bunch of other tweaks
  • Loading branch information
b0bben committed Jul 19, 2011
1 parent 3ed7614 commit 3cd3a0f
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 51 deletions.
2 changes: 1 addition & 1 deletion PlexATV/Classes/HWAppliance.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define LOCAL_DEBUG_ENABLED 1
#define LOCAL_DEBUG_ENABLED 0

#import "HWAppliance.h"
#import "BackRowExtras.h"
Expand Down
3 changes: 0 additions & 3 deletions PlexATV/Classes/HWMediaGridController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
BRCursorControl * _cursorControl;
BRScrollControl * _scroller;
BRPanelControl * _panelControl;
int _lastFocusedControlIndex;
BOOL _shelfWasFocused;
BOOL _gridWasFocused;
}

@property (retain) PlexMediaContainer *shelfMediaContainer;
Expand Down
31 changes: 9 additions & 22 deletions PlexATV/Classes/HWMediaGridController.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ - (id)initWithPlexAllMovies:(PlexMediaContainer *)allMovies andRecentMovies:(Ple
self = [self init];
if (self) {
DLog();
_gridWasFocused = NO;
_shelfWasFocused = NO;
_lastFocusedControlIndex = - 1;

self.shelfMediaContainer = recentMovies;
self.gridMediaContainer = allMovies;
Expand Down Expand Up @@ -88,11 +85,13 @@ -(void)dealloc {
- (void)wasPushed {
[[MachineManager sharedMachineManager] setMachineStateMonitorPriority:NO];
[super wasPushed];
[self _removeAllControls];
[self drawSelf];
}

- (void)wasPopped {
_gridControl = nil;
_shelfControl = nil;
//_gridControl = nil;
//_shelfControl = nil;
[super wasPopped];
}

Expand All @@ -107,15 +106,7 @@ - (void)wasBuried {

-(void)controlWasActivated
{
DLog(@"controlWasActivated");
DLog(@"grid was focused: %@", _gridWasFocused ? @"YES" : @"NO");
DLog(@"shelf was focused: %@", _shelfWasFocused ? @"YES" : @"NO");
DLog(@"last focused index: %d", _lastFocusedControlIndex);
if (_gridWasFocused)
[_gridControl set]
[self _removeAllControls];
[self drawSelf];


[super controlWasActivated];

}
Expand Down Expand Up @@ -272,9 +263,9 @@ - (void) drawSelf
[_scroller setFollowsFocus:YES];
[_scroller setContent:_panelControl];
[_scroller setAcceptsFocus:YES];

[self layoutSubcontrols];

#if LOCAL_DEBUG_ENABLED
DLog(@"drawSelf done");
#endif
Expand Down Expand Up @@ -357,20 +348,16 @@ -(BOOL)brEventAction:(BREvent *)action
NSArray *mediaObjects;

if ([_shelfControl isFocused]) {
index = [_shelfControl focusedIndex];
index = [_shelfControl focusedIndex];
mediaObjects = self.shelfMediaObjects;
_shelfWasFocused = YES;
_lastFocusedControlIndex = index;
#if LOCAL_DEBUG_ENABLED
DLog(@"item in shelf selected. mediaObjects: %d, index:%d",[mediaObjects count], index);
#endif
}

else if ([_gridControl isFocused]) {
index = [_gridControl _indexOfFocusedControl];
index = [_gridControl _indexOfFocusedControl];
mediaObjects = self.gridMediaObjects;
_gridWasFocused = YES;
_lastFocusedControlIndex = index;
#if LOCAL_DEBUG_ENABLED
DLog(@"item in grid selected. mediaObjects: %d, index:%d",[mediaObjects count], index);
#endif
Expand Down
4 changes: 4 additions & 0 deletions PlexATV/Classes/HWPlexDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@
@interface HWPlexDir: SMFMediaMenuController <BRTabControlDelegate> {
PlexMediaContainer* rootContainer;
PlexMediaObject* playbackItem;
NSDictionary* previewControlData;
}

@property (retain) BRTabControl *tabBar;
@property (retain) PlexMediaContainer* rootContainer;
@property (retain) NSArray *items;
@property (retain) NSDictionary* previewControlData;

- (id)initWithRootContainer:(PlexMediaContainer*)container andTabBar:(BRTabControl *)aTabBar;
- (void)showModifyViewedStatusViewForRow:(long)row;
- (void)reselectCurrentTabBarItem;

- (void)createParadeForData:(NSMutableDictionary *)data;
- (void)finishedCreatingParade:(NSDictionary *)data;

//list provider
- (float)heightForRow:(long)row;
Expand Down
71 changes: 52 additions & 19 deletions PlexATV/Classes/HWPlexDir.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@
#import "PlexThemeMusicPlayer.h"
#import "PlexAudioSubsController.h"

#define LOCAL_DEBUG_ENABLED 0
#define LOCAL_DEBUG_ENABLED 1
#define ModifyViewStatusOptionDialog @"ModifyViewStatusOptionDialog"

@implementation HWPlexDir
@synthesize rootContainer;
@synthesize tabBar;
@synthesize items;
@synthesize previewControlData;

#pragma mark -
#pragma mark Object/Class Lifecycle
Expand Down Expand Up @@ -131,7 +132,7 @@ -(void)layoutSubcontrols {

//tab bar same width as list
[self.tabBar setFrame:CGRectMake(listFrame.origin.x+22.f, 567.f, 516.f, 25.f)];

}
}

Expand Down Expand Up @@ -267,40 +268,72 @@ - (id)itemForRow:(long)row {
return pmo.menuItem;
}

#define kParadeItemIndex @"kParadeItemIndex"
#define kParadeItem @"kParadeItem"
#define kParadeControl @"kParadeControl"
- (id)previewControlForItem:(long)item {
id preview = nil;

//stop the timer for parade control, which was setup for previously selected item
[NSObject cancelPreviousPerformRequestsWithTarget:self];

PlexMediaObject* pmo = [self.items objectAtIndex:item];

//we force set the hash so two movies with same title don't end up with the same preview
[self setValue:[pmo description] forKey:@"_previewControlItemHash"];

if ([tabBar selectedTabItemIndex] == TabBarOtherFiltersItemsIndex) {
//parade
#if LOCAL_DEBUG_ENABLED
DLog(@"using parade preview for [%@]", pmo);
#endif
NSMutableArray *imageProxies = [NSMutableArray array];
PlexMediaContainer *subItemsContainer = [pmo contents];
NSArray *subItems = subItemsContainer.directories;
//show parade only after it's been built in the background
//see ticket #108 - Tab switching can be slow

for (PlexMediaObject *pmo in subItems) {
PlexPreviewAsset *previewAsset = [pmo previewAsset];
[imageProxies addObject:[previewAsset imageProxy]];
}
preview = [[[BRMediaParadeControl alloc] init] autorelease];
[preview setImageProxies:imageProxies];
if (self.previewControlData != nil && [[self.previewControlData objectForKey:kParadeItemIndex] longValue] == item) {
//we have already created preview for this item, just return that
return [self.previewControlData objectForKey:kParadeControl];
}
NSNumber *itemIndex = [NSNumber numberWithLong:item]; //need object to be able to store it in dict
NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithObjectsAndKeys:pmo, kParadeItem, itemIndex, kParadeItemIndex, nil];

} else {
#if LOCAL_DEBUG_ENABLED
DLog(@"using standard preview for [%@]", pmo);
#endif
//creating parade in bg, once done this will set self.previewControlData and refresh the preview control
[self performSelectorInBackground:@selector(createParadeForData:) withObject:data];

} else {
//single coverart
preview = pmo.previewControl; //already autoreleased
}
return preview;
}

- (void)finishedCreatingParade:(NSDictionary *)data {
self.previewControlData = data;
[self updatePreviewController];
}

- (void)createParadeForData:(NSMutableDictionary *)data {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
PlexMediaObject *pmo = [data objectForKey:kParadeItem];

NSMutableArray *imageProxies = [NSMutableArray array];
PlexMediaContainer *subItemsContainer = [pmo contents];
NSArray *subItems = subItemsContainer.directories;

for (PlexMediaObject *pmo in subItems) {
PlexPreviewAsset *previewAsset = [pmo previewAsset];
[imageProxies addObject:[previewAsset imageProxy]];
}

id preview = [[[BRMediaParadeControl alloc] init] autorelease];
[preview setImageProxies:imageProxies];

#if LOCAL_DEBUG_ENABLED
DLog(@"parade control created");
#endif

[data setObject:preview forKey:kParadeControl];
[self performSelectorOnMainThread:@selector(finishedCreatingParade:) withObject:data waitUntilDone:NO];

[pool drain];
}

#pragma mark -
#pragma mark BRMenuListItemProvider Delegate
- (BOOL)rowSelectable:(long)selectable {
Expand Down
4 changes: 2 additions & 2 deletions PlexATV/Classes/HWSettingsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@implementation HWSettingsController
@synthesize topLevelController;

#define PlexPluginVersion @"0.8.0"
#define PlexPluginVersion @"0.8.0 RC1"

#define ServersIndex 0
#define ViewSettingsIndex 1
Expand Down Expand Up @@ -194,7 +194,7 @@ -(id)previewControlForItem:(long)item
case PluginVersionNumberIndex: {
// =========== quality setting ===========
[asset setTitle:@"Credit to:"];
[asset setSummary:@"quequick, b0bben and ccjensen"];
[asset setSummary:@"quequick, b0bben and ccjensen, brent112, boots and all the ppl in the forums. <3 you all"];
break;
}
default:
Expand Down
4 changes: 2 additions & 2 deletions PlexATV/Classes/HWUserDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ - (void)_setDefaults {}

+ (void)setupPlexClient {
DLog(@"registering ourselves with the PMS");
[PlexRequest setApplicationName:@"Plex-ATV" version:@"0.8"];
[PlexRequest setApplicationName:@"Plex-ATV" version:@"0.8RC1"];

//tell pms we like direct-stream and we will be sending caps to it
[[PlexPrefs defaultPreferences] setAllowDirectStreaming:YES];
Expand Down Expand Up @@ -164,7 +164,7 @@ + (NSDictionary *)defaultValues {
[NSNumber numberWithBool:YES], PreferencesViewListPosterZoomingEnabled,
[NSNumber numberWithBool:NO], PreferencesPlaybackAudioAC3Enabled,
[NSNumber numberWithBool:NO], PreferencesPlaybackAudioDTSEnabled,
[NSNumber numberWithInt:9], PreferencesPlaybackVideoQualityProfile,
[NSNumber numberWithInt:8], PreferencesPlaybackVideoQualityProfile,
[NSNumber numberWithBool:NO], PreferencesSecuritySettingsLockEnabled,
[NSNumber numberWithInt:0], PreferencesSecurityPasscode,
[NSDictionary dictionary], PersistedTabBarLastSelections,
Expand Down
4 changes: 2 additions & 2 deletions PlexATV/_deb/PLEX.frapplication/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: com.plex.client-plugin
Name: AppleTV PLEX Plugin
Version: 0.0.8.0.5
Version: 0.0.8.0.RC1
Priority: optional
Size: 1083178
Installed-Size: 2662
Depends: beigelist,com.nito,org.tomcool.smframework (>= 0.7.7-2)
Depends: beigelist,com.nito,org.tomcool.smframework (= 0.7.7-2)
Replaces: plex-client-plugin
Architecture: iphoneos-arm
Description: A PLEX Client for Lowtide (beta)
Expand Down

0 comments on commit 3cd3a0f

Please # to comment.