diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-10-09 10:01:19 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2018-10-09 10:01:19 -0400 |
commit | cd14871bf13a25c31fcc038394f41f7e2ab38ad0 (patch) | |
tree | 63b5d790d1653110afb73192f8cea0ef0fec306c | |
parent | 1d031f0f8cd3ef8e0a2c44190b44f762e7264a59 (diff) | |
download | sdl_ios-cd14871bf13a25c31fcc038394f41f7e2ab38ad0.tar.gz |
Fix rootViewController getter / setterbugfix/issue_1101_1100_streaming_rootViewController_fixes
-rwxr-xr-x | SmartDeviceLink/SDLCarWindow.m | 38 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingVideoLifecycleManager.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingVideoLifecycleManager.m | 10 |
5 files changed, 33 insertions, 23 deletions
diff --git a/SmartDeviceLink/SDLCarWindow.m b/SmartDeviceLink/SDLCarWindow.m index 2d6c6f4b2..5e2e02557 100755 --- a/SmartDeviceLink/SDLCarWindow.m +++ b/SmartDeviceLink/SDLCarWindow.m @@ -139,24 +139,26 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Custom Accessors - (void)setRootViewController:(nullable UIViewController *)rootViewController { - if (rootViewController == nil || !self.isVideoStreamStarted) { - _rootViewController = rootViewController; - return; - } - - if (!self.allowMultipleOrientations - && !(rootViewController.supportedInterfaceOrientations == UIInterfaceOrientationMaskPortrait || - rootViewController.supportedInterfaceOrientations == UIInterfaceOrientationMaskLandscapeLeft || - rootViewController.supportedInterfaceOrientations == UIInterfaceOrientationMaskLandscapeRight)) { - @throw [NSException sdl_carWindowOrientationException]; - } - - if (self.streamManager.screenSize.width != 0) { - rootViewController.view.frame = CGRectMake(0, 0, self.streamManager.screenSize.width, self.streamManager.screenSize.height); - rootViewController.view.bounds = rootViewController.view.frame; - } - - _rootViewController = rootViewController; + dispatch_async(dispatch_get_main_queue(), ^{ + if (rootViewController == nil || !self.isVideoStreamStarted) { + self->_rootViewController = rootViewController; + return; + } + + if (!self.allowMultipleOrientations + && !(rootViewController.supportedInterfaceOrientations == UIInterfaceOrientationMaskPortrait || + rootViewController.supportedInterfaceOrientations == UIInterfaceOrientationMaskLandscapeLeft || + rootViewController.supportedInterfaceOrientations == UIInterfaceOrientationMaskLandscapeRight)) { + @throw [NSException sdl_carWindowOrientationException]; + } + + if (self.streamManager.screenSize.width != 0) { + rootViewController.view.frame = CGRectMake(0, 0, self.streamManager.screenSize.width, self.streamManager.screenSize.height); + rootViewController.view.bounds = rootViewController.view.frame; + } + + self->_rootViewController = rootViewController; + }); } #pragma mark - Private Helpers diff --git a/SmartDeviceLink/SDLStreamingMediaManager.h b/SmartDeviceLink/SDLStreamingMediaManager.h index f9df79067..6be499bec 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.h +++ b/SmartDeviceLink/SDLStreamingMediaManager.h @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN /** This property is used for SDLCarWindow, the ability to stream any view controller. To start, you must set an initial view controller on `SDLStreamingMediaConfiguration` `rootViewController`. After streaming begins, you can replace that view controller with a new root by placing the new view controller into this property. */ -@property (nonatomic, strong) UIViewController *rootViewController; +@property (nonatomic, strong, nullable) UIViewController *rootViewController; /** A haptic interface that can be updated to reparse views within the window you've provided. Send a `SDLDidUpdateProjectionView` notification or call the `updateInterfaceLayout` method to reparse. The "output" of this haptic interface occurs in the `touchManager` property where it will call the delegate. diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m index 95819666a..36a26c8ac 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.m +++ b/SmartDeviceLink/SDLStreamingMediaManager.m @@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN return self.audioLifecycleManager.audioManager; } -- (UIViewController *)rootViewController { +- (nullable UIViewController *)rootViewController { return self.videoLifecycleManager.rootViewController; } @@ -160,7 +160,7 @@ NS_ASSUME_NONNULL_BEGIN } #pragma mark - Setters -- (void)setRootViewController:(UIViewController *)rootViewController { +- (void)setRootViewController:(nullable UIViewController *)rootViewController { self.videoLifecycleManager.rootViewController = rootViewController; } diff --git a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h index b2c8df48f..808d86c4b 100644 --- a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h +++ b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.h @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN * Touch Manager responsible for providing touch event notifications. */ @property (nonatomic, strong, readonly) SDLTouchManager *touchManager; -@property (nonatomic, strong) UIViewController *rootViewController; +@property (nonatomic, strong, nullable) UIViewController *rootViewController; @property (strong, nonatomic, readonly, nullable) SDLCarWindow *carWindow; /** diff --git a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m index 4f8e47e77..5302e287d 100644 --- a/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingVideoLifecycleManager.m @@ -734,7 +734,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N #pragma mark Setters / Getters -- (void)setRootViewController:(UIViewController *)rootViewController { +- (void)setRootViewController:(nullable UIViewController *)rootViewController { if (self.focusableItemManager != nil) { self.focusableItemManager.viewController = rootViewController; } @@ -744,6 +744,14 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N } } +- (nullable UIViewController *)rootViewController { + if (self.carWindow != nil) { + return self.carWindow.rootViewController; + } else { + return nil; + } +} + - (BOOL)isAppStateVideoStreamCapable { return [self.appStateMachine isCurrentState:SDLAppStateActive]; } |