diff options
author | NicoleYarroch <nicole@livio.io> | 2019-05-31 11:26:46 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-05-31 11:26:46 -0400 |
commit | ff55c388cb42b248fb86058edda8578a5433cb72 (patch) | |
tree | 370dc3920f7dc1468fde1fffbec8f11d0a79ec74 | |
parent | 6e83a5642afe817dca4d0011737f384cac13c6b8 (diff) | |
download | sdl_ios-ff55c388cb42b248fb86058edda8578a5433cb72.tar.gz |
Refactored example app starting manager methods
-rw-r--r-- | Example Apps/Example ObjC/ProxyManager.m | 10 | ||||
-rw-r--r-- | Example Apps/Example Swift/ProxyManager.swift | 11 |
2 files changed, 11 insertions, 10 deletions
diff --git a/Example Apps/Example ObjC/ProxyManager.m b/Example Apps/Example ObjC/ProxyManager.m index c045531ef..453e843eb 100644 --- a/Example Apps/Example ObjC/ProxyManager.m +++ b/Example Apps/Example ObjC/ProxyManager.m @@ -109,14 +109,14 @@ NS_ASSUME_NONNULL_BEGIN } - (void)sdlex_setupConfigurationWithLifecycleConfiguration:(SDLLifecycleConfiguration *)lifecycleConfiguration { - if (self.sdlManager == nil) { - SDLConfiguration *config = [SDLConfiguration configurationWithLifecycle:lifecycleConfiguration lockScreen:[SDLLockScreenConfiguration enabledConfigurationWithAppIcon:[UIImage imageNamed:ExampleAppLogoName] backgroundColor:nil] logging:[self.class sdlex_logConfiguration] fileManager:[SDLFileManagerConfiguration defaultConfiguration]]; - self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self]; - [self sdlex_startManager]; - } else { + if (self.sdlManager != nil) { // Manager already created, just start it again. [self sdlex_startManager]; + return; } + SDLConfiguration *config = [SDLConfiguration configurationWithLifecycle:lifecycleConfiguration lockScreen:[SDLLockScreenConfiguration enabledConfigurationWithAppIcon:[UIImage imageNamed:ExampleAppLogoName] backgroundColor:nil] logging:[self.class sdlex_logConfiguration] fileManager:[SDLFileManagerConfiguration defaultConfiguration]]; + self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self]; + [self sdlex_startManager]; } + (SDLLifecycleConfiguration *)sdlex_setLifecycleConfigurationPropertiesOnConfiguration:(SDLLifecycleConfiguration *)config { diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift index a645b0c1a..40a703e4a 100644 --- a/Example Apps/Example Swift/ProxyManager.swift +++ b/Example Apps/Example Swift/ProxyManager.swift @@ -43,14 +43,15 @@ extension ProxyManager { /// /// - Parameter connectionType: The type of transport layer to use. func start(with proxyTransportType: ProxyTransportType) { - if sdlManager == nil { - delegate?.didChangeProxyState(ProxyState.searching) - sdlManager = SDLManager(configuration: proxyTransportType == .iap ? ProxyManager.connectIAP() : ProxyManager.connectTCP(), delegate: self) - startManager() - } else { + guard sdlManager == nil else { // Manager already created, just start it again. startManager() + return } + + delegate?.didChangeProxyState(ProxyState.searching) + sdlManager = SDLManager(configuration: proxyTransportType == .iap ? ProxyManager.connectIAP() : ProxyManager.connectTCP(), delegate: self) + startManager() } /// Attempts to close the connection between the this app and the car's head unit. The `SDLManagerDelegate`'s `managerDidDisconnect()` is called when connection is actually closed. |