mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-07 16:36:24 +00:00
Avoid firing off HTTP requests as we enter the background when entering home from streaming
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
NSArray* _sortedAppList;
|
||||
NSCache* _boxArtCache;
|
||||
UIButton* _pullArrow;
|
||||
bool _background;
|
||||
}
|
||||
static NSMutableSet* hostList;
|
||||
|
||||
@@ -620,6 +621,11 @@ static NSMutableSet* hostList;
|
||||
name: UIApplicationWillEnterForegroundNotification
|
||||
object: nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
selector: @selector(handleEnterBackground)
|
||||
name: UIApplicationWillResignActiveNotification
|
||||
object: nil];
|
||||
|
||||
[self updateHosts];
|
||||
[self.view addSubview:hostScrollView];
|
||||
[self.view addSubview:_pullArrow];
|
||||
@@ -632,12 +638,23 @@ static NSMutableSet* hostList;
|
||||
|
||||
-(void)handleReturnToForeground
|
||||
{
|
||||
_background = NO;
|
||||
|
||||
[_discMan startDiscovery];
|
||||
|
||||
// This will refresh the applist when a paired host is selected
|
||||
if (_selectedHost != nil && _selectedHost.pairState == PairStatePaired) {
|
||||
[self hostClicked:_selectedHost view:nil];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)handleEnterBackground
|
||||
{
|
||||
_background = YES;
|
||||
|
||||
[_discMan stopDiscovery];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
@@ -651,9 +668,14 @@ static NSMutableSet* hostList;
|
||||
[self.navigationController.navigationBar setShadowImage:fakeImage];
|
||||
[self.navigationController.navigationBar setBackgroundImage:fakeImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
|
||||
|
||||
[_discMan startDiscovery];
|
||||
|
||||
[self handleReturnToForeground];
|
||||
// We can get here on home press while streaming
|
||||
// since the stream view segues to us just before
|
||||
// entering the background. We can't check the app
|
||||
// state here (since it's in transition), so we have
|
||||
// to use this variable that we set.
|
||||
if (!_background) {
|
||||
[_discMan startDiscovery];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
|
||||
Reference in New Issue
Block a user