@@ -70,13 +70,13 @@ class PreloadChoicesOperation extends Task {
7070 private final WindowCapability defaultMainWindowCapability ;
7171 private final String displayName ;
7272 private final HashSet <ChoiceCell > cellsToUpload ;
73- private final CompletionListener completionListener ;
73+ private final BaseChoiceSetManager . ChoiceSetCompletionListener completionListener ;
7474 private boolean isRunning ;
7575 private final boolean isVROptional ;
7676 private boolean choiceError = false ;
7777
7878 PreloadChoicesOperation (ISdl internalInterface , FileManager fileManager , String displayName , WindowCapability defaultMainWindowCapability ,
79- Boolean isVROptional , LinkedHashSet <ChoiceCell > cellsToPreload , CompletionListener listener ) {
79+ Boolean isVROptional , LinkedHashSet <ChoiceCell > cellsToPreload , BaseChoiceSetManager . ChoiceSetCompletionListener listener ) {
8080 super ("PreloadChoicesOperation" );
8181 this .internalInterface = new WeakReference <>(internalInterface );
8282 this .fileManager = new WeakReference <>(fileManager );
@@ -141,7 +141,7 @@ public void onComplete(Map<String, String> errors) {
141141
142142 private void preloadCells () {
143143 isRunning = true ;
144- List <CreateInteractionChoiceSet > choiceRPCs = new ArrayList <>(cellsToUpload .size ());
144+ final List <CreateInteractionChoiceSet > choiceRPCs = new ArrayList <>(cellsToUpload .size ());
145145 for (ChoiceCell cell : cellsToUpload ) {
146146 CreateInteractionChoiceSet csCell = choiceFromCell (cell );
147147 if (csCell != null ) {
@@ -151,13 +151,15 @@ private void preloadCells() {
151151
152152 if (choiceRPCs .size () == 0 ) {
153153 DebugTool .logError (TAG , " All Choice cells to send are null, so the choice set will not be shown" );
154- completionListener .onComplete (true );
154+ completionListener .onComplete (true , null );
155155 isRunning = false ;
156156 return ;
157157 }
158158
159159 if (internalInterface .get () != null ) {
160160 internalInterface .get ().sendRPCs (choiceRPCs , new OnMultipleRequestListener () {
161+ final HashSet <ChoiceCell > failedChoiceCells = new HashSet <>();
162+
161163 @ Override
162164 public void onUpdate (int remainingRequests ) {
163165
@@ -167,7 +169,7 @@ public void onUpdate(int remainingRequests) {
167169 public void onFinished () {
168170 isRunning = false ;
169171 DebugTool .logInfo (TAG , "Finished pre loading choice cells" );
170- completionListener .onComplete (!choiceError );
172+ completionListener .onComplete (!choiceError , ! choiceError ? null : failedChoiceCells );
171173 choiceError = false ;
172174 PreloadChoicesOperation .super .onFinished ();
173175 }
@@ -177,13 +179,23 @@ public void onResponse(int correlationId, RPCResponse response) {
177179 if (!response .getSuccess ()) {
178180 DebugTool .logError (TAG , "There was an error uploading a choice cell: " + response .getInfo () + " resultCode: " + response .getResultCode ());
179181 choiceError = true ;
182+ for (CreateInteractionChoiceSet choiceSet : choiceRPCs ) {
183+ if (choiceSet .getCorrelationID () == correlationId ) {
184+ int choiceId = choiceSet .getChoiceSet ().get (0 ).getChoiceID ();
185+ for (ChoiceCell cell : cellsToUpload ) {
186+ if (cell .getChoiceId () == choiceId ) {
187+ failedChoiceCells .add (cell );
188+ }
189+ }
190+ }
191+ }
180192 }
181193 }
182194 });
183195 } else {
184196 DebugTool .logError (TAG , "Internal Interface null in preload choice operation" );
185197 isRunning = false ;
186- completionListener .onComplete (false );
198+ completionListener .onComplete (false , cellsToUpload );
187199 }
188200 }
189201
0 commit comments