Fix running state refresh on app grid

This commit is contained in:
Cameron Gutman
2018-12-27 19:54:27 -08:00
parent befef62b2f
commit 94c9433b99
2 changed files with 25 additions and 4 deletions
+25 -3
View File
@@ -9,6 +9,8 @@
#import "UIAppView.h" #import "UIAppView.h"
#import "AppAssetManager.h" #import "AppAssetManager.h"
static const float REFRESH_CYCLE = 2.0f;
@implementation UIAppView { @implementation UIAppView {
TemporaryApp* _app; TemporaryApp* _app;
UIButton* _appButton; UIButton* _appButton;
@@ -50,13 +52,13 @@ static UIImage* noImage;
[self addSubview:_appButton]; [self addSubview:_appButton];
[self sizeToFit]; [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 // Rasterizing the cell layer increases rendering performance by quite a bit
self.layer.shouldRasterize = YES; self.layer.shouldRasterize = YES;
self.layer.rasterizationScale = [UIScreen mainScreen].scale; self.layer.rasterizationScale = [UIScreen mainScreen].scale;
[self updateAppImage];
[self startUpdateLoop];
return self; return self;
} }
@@ -70,6 +72,9 @@ static UIImage* noImage;
_appOverlay = nil; _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]) { if ([_app.id isEqualToString:_app.host.currentGame]) {
// Only create the app overlay if needed // Only create the app overlay if needed
_appOverlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Play"]]; _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 @end
@@ -982,7 +982,6 @@ static NSMutableSet* hostList;
TemporaryApp* app = _sortedAppList[indexPath.row]; TemporaryApp* app = _sortedAppList[indexPath.row];
UIAppView* appView = [[UIAppView alloc] initWithApp:app cache:_boxArtCache andCallback:self]; UIAppView* appView = [[UIAppView alloc] initWithApp:app cache:_boxArtCache andCallback:self];
[appView updateAppImage];
if (appView.bounds.size.width > 10.0) { if (appView.bounds.size.width > 10.0) {
CGFloat scale = cell.bounds.size.width / appView.bounds.size.width; CGFloat scale = cell.bounds.size.width / appView.bounds.size.width;