disable background hostCard update while streaming

This commit is contained in:
TrueZhuanjia
2025-07-21 13:01:19 +08:00
parent 0728959ebe
commit eb41536749
3 changed files with 16 additions and 6 deletions
+1
View File
@@ -16,6 +16,7 @@
- (void)wakeupButtonTappedForHost:(TemporaryHost *)host;
- (void)pairButtonTappedForHost:(TemporaryHost *)host;
- (void)hostCardLongPressed:(TemporaryHost *)host view:(UIView *)view;
- (bool)isStreaming;
@end
+3 -1
View File
@@ -509,10 +509,12 @@ static const float REFRESH_CYCLE = 2.0f;
return;
}
NSLog(@"hostCard update loop %f", CACurrentMediaTime());
[self updateContentsForHost:_host];
// Queue the next refresh cycle
[self performSelector:@selector(updateLoop) withObject:self afterDelay:REFRESH_CYCLE];
if(![self.delegate isStreaming]) [self performSelector:@selector(updateLoop) withObject:self afterDelay:REFRESH_CYCLE];
}
- (void) updateContentsForHost:(TemporaryHost*)host {
@@ -69,6 +69,7 @@
NSCache* _boxArtCache;
bool _background;
bool _enteredAppView;
bool _settingsViewExpanded;
UIView* menuSeparator;
UIView* snapshot;
SettingsViewController* settingsViewController;
@@ -1119,6 +1120,7 @@ static NSMutableSet* hostList;
- (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position {
settingsViewController = (SettingsViewController*)[revealController rearViewController];
revealController.navBarMenuDelegate = settingsViewController;
_settingsViewExpanded = position != FrontViewPositionLeft;
if (position == FrontViewPositionLeft) {
self.navigationItem.leftBarButtonItems = @[_settingsButton];
}
@@ -1788,11 +1790,12 @@ static NSMutableSet* hostList;
[super viewWillAppear:NO];
/* this makes background color works*/
/*
for (UIView *subview in self.view.subviews) {
[subview removeFromSuperview]; // 暂时移除所有子视图
}*/
if(!_settingsViewExpanded){
for (UIView *subview in self.view.subviews) {
[subview removeFromSuperview]; // 暂时移除所有子视图
}
}
// We can get here on home press while streaming
// since the stream view segues to us just before
@@ -2008,6 +2011,10 @@ static NSMutableSet* hostList;
return !self.revealViewController.isStreaming && _enteredAppView;
}
- (bool)isStreaming{
return self.revealViewController.isStreaming;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AppCell" forIndexPath:indexPath];