summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLPreloadChoicesOperation.m
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2018-05-24 11:50:38 -0400
committerJoel Fischer <joeljfischer@gmail.com>2018-05-24 11:50:38 -0400
commit5690738a3b9471aedc9923edaf17c861cc4c26ef (patch)
tree3b2e8c2f15c92d642175d22eef82f8d256279660 /SmartDeviceLink/SDLPreloadChoicesOperation.m
parent6b85bc675057747ba94a003a8275e3aa2c7fea93 (diff)
downloadsdl_ios-5690738a3b9471aedc9923edaf17c861cc4c26ef.tar.gz
Add new ChoiceManager operations
Diffstat (limited to 'SmartDeviceLink/SDLPreloadChoicesOperation.m')
-rw-r--r--SmartDeviceLink/SDLPreloadChoicesOperation.m30
1 files changed, 28 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLPreloadChoicesOperation.m b/SmartDeviceLink/SDLPreloadChoicesOperation.m
index 37392fe1e..efbafd3b7 100644
--- a/SmartDeviceLink/SDLPreloadChoicesOperation.m
+++ b/SmartDeviceLink/SDLPreloadChoicesOperation.m
@@ -18,6 +18,7 @@
#import "SDLError.h"
#import "SDLFileManager.h"
#import "SDLImage.h"
+#import "SDLLogMacros.h"
NS_ASSUME_NONNULL_BEGIN
@@ -77,6 +78,13 @@ NS_ASSUME_NONNULL_BEGIN
}
[self.fileManager uploadArtworks:[artworksToUpload copy] completionHandler:^(NSArray<NSString *> * _Nonnull artworkNames, NSError * _Nullable error) {
+ if (error != nil) {
+ SDLLogE(@"Error uploading choice artworks: %@", error);
+ } else {
+ SDLLogD(@"Finished uploading choice artworks");
+ SDLLogV(@"%@", artworkNames);
+ }
+
completionHandler(error);
}];
}
@@ -87,7 +95,25 @@ NS_ASSUME_NONNULL_BEGIN
[choiceRPCs addObject:[self sdl_choiceFromCell:cell]];
}
-
+ __weak typeof(self) weakSelf = self;
+ __block NSMutableDictionary<SDLRPCRequest *, NSError *> *errors = [NSMutableDictionary dictionary];
+ [self.connectionManager sendRequests:[choiceRPCs copy] progressHandler:^(__kindof SDLRPCRequest * _Nonnull request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error, float percentComplete) {
+ if (error != nil) {
+ errors[request] = error;
+ }
+ } completionHandler:^(BOOL success) {
+ if (!success) {
+ if (weakSelf.completionHandler != nil) {
+ weakSelf.completionHandler([NSError sdl_choiceSetManager_choiceUploadFailed:errors]);
+ }
+ } else {
+ if (weakSelf.completionHandler != nil) {
+ weakSelf.completionHandler(nil);
+ }
+ }
+
+ [weakSelf finishOperation];
+ }];
}
#pragma mark - Assembling Choice Data
@@ -107,7 +133,7 @@ NS_ASSUME_NONNULL_BEGIN
SDLImage *image = [self.displayCapabilities hasImageFieldOfName:SDLImageFieldNameChoiceImage] ? [[SDLImage alloc] initWithName:cell.artwork.name] : nil;
SDLImage *secondaryImage = [self.displayCapabilities hasImageFieldOfName:SDLImageFieldNameChoiceSecondaryImage] ? [[SDLImage alloc] initWithName:cell.secondaryArtwork.name] : nil;
- SDLChoice *choice = [[SDLChoice alloc] initWithId:cell.choiceId menuName:menuName vrCommands:(NSArray<NSString *> * _Nonnull)vrCommands image:image secondaryText:secondaryText secondaryImage:secondaryImage tertiaryText:tertiaryText];
+ SDLChoice *choice = [[SDLChoice alloc] initWithId:cell.choiceId menuName:(NSString *_Nonnull)menuName vrCommands:(NSArray<NSString *> * _Nonnull)vrCommands image:image secondaryText:secondaryText secondaryImage:secondaryImage tertiaryText:tertiaryText];
return [[SDLCreateInteractionChoiceSet alloc] initWithId:(UInt32)choice.choiceID choiceSet:@[choice]];
}