Skip to content

Commit 76cbf36

Browse files
author
Julian Kast
committed
Update voiceCommand listeners from previous uploads
1 parent d5da8a0 commit 76cbf36

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

base/src/main/java/com/smartdevicelink/managers/screen/menu/VoiceCommandUpdateOperation.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ private void start() {
5353
onFinished();
5454
return;
5555
}
56+
// Check if a voiceCommand has already been uploaded and update its VoiceCommandSelectionListener to
57+
// prevent calling the wrong listener in a case where a voice command was uploaded and then its voiceCommandSelectionListener was updated in another upload.
58+
if (pendingVoiceCommands != null && pendingVoiceCommands.size() > 0) {
59+
for (VoiceCommand voiceCommand : pendingVoiceCommands) {
60+
if (currentVoiceCommands.contains(voiceCommand)) {
61+
currentVoiceCommands.get(currentVoiceCommands.indexOf(voiceCommand)).setVoiceCommandSelectionListener(voiceCommand.getVoiceCommandSelectionListener());
62+
}
63+
}
64+
}
5665

5766
sendDeleteCurrentVoiceCommands(new CompletionListener() {
5867
@Override
@@ -169,7 +178,7 @@ private void sendCurrentVoiceCommands(final CompletionListener listener) {
169178

170179
if (voiceCommandsToAdd.size() == 0) {
171180
if (listener != null) {
172-
listener.onComplete(true); // no voice commands to send doesnt mean that its an error
181+
listener.onComplete(true); // no voice commands to send doesn't mean that its an error
173182
}
174183
return;
175184
}

0 commit comments

Comments
 (0)