mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +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;
|
NSArray* _sortedAppList;
|
||||||
NSCache* _boxArtCache;
|
NSCache* _boxArtCache;
|
||||||
UIButton* _pullArrow;
|
UIButton* _pullArrow;
|
||||||
|
bool _background;
|
||||||
}
|
}
|
||||||
static NSMutableSet* hostList;
|
static NSMutableSet* hostList;
|
||||||
|
|
||||||
@@ -620,6 +621,11 @@ static NSMutableSet* hostList;
|
|||||||
name: UIApplicationWillEnterForegroundNotification
|
name: UIApplicationWillEnterForegroundNotification
|
||||||
object: nil];
|
object: nil];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
|
selector: @selector(handleEnterBackground)
|
||||||
|
name: UIApplicationWillResignActiveNotification
|
||||||
|
object: nil];
|
||||||
|
|
||||||
[self updateHosts];
|
[self updateHosts];
|
||||||
[self.view addSubview:hostScrollView];
|
[self.view addSubview:hostScrollView];
|
||||||
[self.view addSubview:_pullArrow];
|
[self.view addSubview:_pullArrow];
|
||||||
@@ -632,12 +638,23 @@ static NSMutableSet* hostList;
|
|||||||
|
|
||||||
-(void)handleReturnToForeground
|
-(void)handleReturnToForeground
|
||||||
{
|
{
|
||||||
|
_background = NO;
|
||||||
|
|
||||||
|
[_discMan startDiscovery];
|
||||||
|
|
||||||
// This will refresh the applist when a paired host is selected
|
// This will refresh the applist when a paired host is selected
|
||||||
if (_selectedHost != nil && _selectedHost.pairState == PairStatePaired) {
|
if (_selectedHost != nil && _selectedHost.pairState == PairStatePaired) {
|
||||||
[self hostClicked:_selectedHost view:nil];
|
[self hostClicked:_selectedHost view:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)handleEnterBackground
|
||||||
|
{
|
||||||
|
_background = YES;
|
||||||
|
|
||||||
|
[_discMan stopDiscovery];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated
|
- (void)viewDidAppear:(BOOL)animated
|
||||||
{
|
{
|
||||||
[super viewDidAppear:animated];
|
[super viewDidAppear:animated];
|
||||||
@@ -651,9 +668,14 @@ static NSMutableSet* hostList;
|
|||||||
[self.navigationController.navigationBar setShadowImage:fakeImage];
|
[self.navigationController.navigationBar setShadowImage:fakeImage];
|
||||||
[self.navigationController.navigationBar setBackgroundImage:fakeImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
|
[self.navigationController.navigationBar setBackgroundImage:fakeImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
|
||||||
|
|
||||||
[_discMan startDiscovery];
|
// We can get here on home press while streaming
|
||||||
|
// since the stream view segues to us just before
|
||||||
[self handleReturnToForeground];
|
// 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
|
- (void)viewDidDisappear:(BOOL)animated
|
||||||
|
|||||||
Reference in New Issue
Block a user