diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2016-07-28 10:33:47 -0700 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2016-07-28 10:33:47 -0700 |
commit | 9f0a635a2633f00e5b07a8048da521bb6259cd22 (patch) | |
tree | 50c96fd1096c95fa09b2089edd5434427b43d58a | |
parent | e6b44e85ff659d724e6e60280de8f10b110d8da3 (diff) | |
download | sdl_ios-9f0a635a2633f00e5b07a8048da521bb6259cd22.tar.gz |
Moved the observing of application state changes to Streaming Media Manager.
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.m | 19 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTouchManager.h | 8 | ||||
-rw-r--r-- | SmartDeviceLink/SDLTouchManager.m | 29 |
3 files changed, 32 insertions, 24 deletions
diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m index c1877d7b5..0159c5f70 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.m +++ b/SmartDeviceLink/SDLStreamingMediaManager.m @@ -60,6 +60,16 @@ NS_ASSUME_NONNULL_BEGIN _audioStartBlock = nil; _touchManager = [[SDLTouchManager alloc] init]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(sdl_applicationDidEnterBackground:) + name:UIApplicationDidEnterBackgroundNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(sdl_applicationDidResignActive:) + name:UIApplicationWillResignActiveNotification + object:nil]; return self; } @@ -358,6 +368,15 @@ void sdl_videoEncoderOutputCallback(void *outputCallbackRefCon, void *sourceFram return streamingDataQueue; } +#pragma mark - Private Functions +- (void)sdl_applicationDidEnterBackground:(NSNotification*)notification { + [self.touchManager cancelPendingTouches]; +} + +- (void)sdl_applicationDidResignActive:(NSNotification*)notification { + [self.touchManager cancelPendingTouches]; +} + @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLTouchManager.h b/SmartDeviceLink/SDLTouchManager.h index c15f12cb3..b89917218 100644 --- a/SmartDeviceLink/SDLTouchManager.h +++ b/SmartDeviceLink/SDLTouchManager.h @@ -50,6 +50,14 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, assign, getter=isTouchEnabled) BOOL touchEnabled; +/** + * @abstract + * Cancels pending touch event timers that may be in progress. + * @remark + * Currently only impacts the timer used to register single taps. + */ +- (void)cancelPendingTouches; + @end NS_ASSUME_NONNULL_END
\ No newline at end of file diff --git a/SmartDeviceLink/SDLTouchManager.m b/SmartDeviceLink/SDLTouchManager.m index 593c16338..f987191b7 100644 --- a/SmartDeviceLink/SDLTouchManager.m +++ b/SmartDeviceLink/SDLTouchManager.m @@ -88,19 +88,14 @@ static NSUInteger const MaximumNumberOfTouches = 2; _tapDistanceThreshold = 50.0f; _touchEnabled = YES; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(sdl_applicationDidEnterBackground:) - name:UIApplicationDidEnterBackgroundNotification - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(sdl_applicationDidResignActive:) - name:UIApplicationWillResignActiveNotification - object:nil]; - return self; } +#pragma mark - Public +- (void)cancelPendingTouches { + [self sdl_cancelSingleTapTimer]; +} + #pragma mark - SDLProxyListener Delegate - (void)onProxyOpened { } - (void)onProxyClosed { } @@ -281,20 +276,6 @@ static NSUInteger const MaximumNumberOfTouches = 2; self.singleTapTimer = NULL; } -- (void)sdl_applicationDidEnterBackground:(NSNotification*)notification { - if (self.singleTapTimer != NULL) { - [SDLDebugTool logInfo:@"Application is Entering Background. Canceling Single Touch Timer."]; - [self sdl_cancelSingleTapTimer]; - } -} - -- (void)sdl_applicationDidResignActive:(NSNotification*)notification { - if (self.singleTapTimer != NULL) { - [SDLDebugTool logInfo:@"Application is Resigning Active State. Canceling Single Touch Timer."]; - [self sdl_cancelSingleTapTimer]; - } -} - @end NS_ASSUME_NONNULL_END
\ No newline at end of file |