diff --git a/Limelight/UIAppView.m b/Limelight/UIAppView.m index 127d311..f08af8e 100644 --- a/Limelight/UIAppView.m +++ b/Limelight/UIAppView.m @@ -9,6 +9,8 @@ #import "UIAppView.h" #import "AppAssetManager.h" +static const float REFRESH_CYCLE = 2.0f; + @implementation UIAppView { TemporaryApp* _app; UIButton* _appButton; @@ -50,13 +52,13 @@ static UIImage* noImage; [self addSubview:_appButton]; [self sizeToFit]; - _appButton.frame = CGRectMake(0, 0, noImage.size.width, noImage.size.height); - self.frame = CGRectMake(0, 0, noImage.size.width, noImage.size.height); - // Rasterizing the cell layer increases rendering performance by quite a bit self.layer.shouldRasterize = YES; self.layer.rasterizationScale = [UIScreen mainScreen].scale; + [self updateAppImage]; + [self startUpdateLoop]; + return self; } @@ -70,6 +72,9 @@ static UIImage* noImage; _appOverlay = nil; } + _appButton.frame = CGRectMake(0, 0, noImage.size.width, noImage.size.height); + self.frame = CGRectMake(0, 0, noImage.size.width, noImage.size.height); + if ([_app.id isEqualToString:_app.host.currentGame]) { // Only create the app overlay if needed _appOverlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Play"]]; @@ -163,4 +168,21 @@ static UIImage* noImage; } +- (void) startUpdateLoop { + [self performSelector:@selector(updateLoop) withObject:self afterDelay:REFRESH_CYCLE]; +} + +- (void) updateLoop { + // Update the app image if neccessary + if ((_appOverlay != nil && ![_app.id isEqualToString:_app.host.currentGame]) || + (_appOverlay == nil && [_app.id isEqualToString:_app.host.currentGame])) { + [self updateAppImage]; + } + + // Stop updating when we detach from our parent view + if (self.superview != nil) { + [self performSelector:@selector(updateLoop) withObject:self afterDelay:REFRESH_CYCLE]; + } +} + @end diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index 5fac30d..0b8459f 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -982,7 +982,6 @@ static NSMutableSet* hostList; TemporaryApp* app = _sortedAppList[indexPath.row]; UIAppView* appView = [[UIAppView alloc] initWithApp:app cache:_boxArtCache andCallback:self]; - [appView updateAppImage]; if (appView.bounds.size.width > 10.0) { CGFloat scale = cell.bounds.size.width / appView.bounds.size.width;