summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2019-06-05 10:21:17 -0400
committerNicoleYarroch <nicole@livio.io>2019-06-05 10:21:17 -0400
commitb7f13d11037bb29a213fc07036489c97d897ce36 (patch)
tree1d7ffae5b5c847d1fc235114c4baab0625525860
parente16e3607ec3916d5fef9cb001fceb71c1755bb91 (diff)
downloadsdl_ios-b7f13d11037bb29a213fc07036489c97d897ce36.tar.gz
Operation finished if no text or image buttons sent
-rw-r--r--SmartDeviceLink/SDLSoftButtonReplaceOperation.m16
1 files changed, 11 insertions, 5 deletions
diff --git a/SmartDeviceLink/SDLSoftButtonReplaceOperation.m b/SmartDeviceLink/SDLSoftButtonReplaceOperation.m
index 82f5b4ffe..c967e10a9 100644
--- a/SmartDeviceLink/SDLSoftButtonReplaceOperation.m
+++ b/SmartDeviceLink/SDLSoftButtonReplaceOperation.m
@@ -56,11 +56,17 @@ NS_ASSUME_NONNULL_BEGIN
SDLLogW(@"Soft button images are not supported. Attempting to send text-only soft buttons. If any button does not contain text, no buttons will be sent.");
// Send text buttons if all the soft buttons have text
- [self sdl_sendCurrentStateTextOnlySoftButtonsWithCompletionHandler:^{}];
+ __weak typeof(self) weakself = self;
+ [self sdl_sendCurrentStateTextOnlySoftButtonsWithCompletionHandler:^(BOOL success) {
+ if (!success) {
+ SDLLogE(@"Head unit does not support images and some of the soft buttons do not have text, so none of the buttons will be sent.");
+ [weakself finishOperation];
+ }
+ }];
} else if ([self sdl_currentStateHasImages] && ![self sdl_allCurrentStateImagesAreUploaded]) {
// If there are images that aren't uploaded
// Send text buttons if all the soft buttons have text
- [self sdl_sendCurrentStateTextOnlySoftButtonsWithCompletionHandler:^{}];
+ [self sdl_sendCurrentStateTextOnlySoftButtonsWithCompletionHandler:^(BOOL success) {}];
// Upload initial images
__weak typeof(self) weakself = self;
@@ -205,7 +211,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
Returns text soft buttons representing the current states of the button objects, or returns if _any_ of the buttons' current states are image only buttons.
*/
-- (void)sdl_sendCurrentStateTextOnlySoftButtonsWithCompletionHandler:(void (^)(void))handler {
+- (void)sdl_sendCurrentStateTextOnlySoftButtonsWithCompletionHandler:(void (^)(BOOL success))handler {
if (self.isCancelled) {
[self finishOperation];
}
@@ -216,7 +222,7 @@ NS_ASSUME_NONNULL_BEGIN
SDLSoftButton *button = buttonObject.currentStateSoftButton;
if (button.text == nil) {
SDLLogW(@"Attempted to create text buttons, but some buttons don't support text, so no text-only soft buttons will be sent");
- handler();
+ handler(NO);
return;
}
@@ -235,7 +241,7 @@ NS_ASSUME_NONNULL_BEGIN
}
SDLLogD(@"Finished sending text only soft buttons");
- handler();
+ handler(YES);
}];
}