mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 14:11:35 +00:00
Fix running state refresh on app grid
This commit is contained in:
+25
-3
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user