diff options
author | NicoleYarroch <nicole@livio.io> | 2019-08-12 09:04:31 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-08-12 09:04:31 -0400 |
commit | aac1e6ef72cb7e69845c9cebda81171eaf55ea6d (patch) | |
tree | a9befaadcfc8adc1ed9ce21bbc28c8c7052f3f13 | |
parent | 6b31b954760e2b1c4e87d3dc45a88e8566a9df44 (diff) | |
download | sdl_android-aac1e6ef72cb7e69845c9cebda81171eaf55ea6d.tar.gz |
Refactored the dismiss keyboard methods
2 files changed, 28 insertions, 17 deletions
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java index 3dcb6fbaf..103612c74 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java @@ -403,6 +403,9 @@ abstract class BaseChoiceSetManager extends BaseSubManager { pendingPresentOperation = executor.submit(keyboardOp); } + /* + * Cancels the keyboard-only interface if it is currently showing + */ public void dismissKeyboard() { if (currentlyPresentedKeyboardOperation == null || !currentlyPresentedKeyboardOperation.isExecuting()) { return; } currentlyPresentedKeyboardOperation.dismissKeyboard(); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java index 159aba3ad..30d2b75e6 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java @@ -127,29 +127,37 @@ class PresentKeyboardOperation extends AsynchronousOperation { } + /* + * Cancels a currently presented keyboard + */ void dismissKeyboard() { if (Thread.currentThread().isInterrupted()) { + // This operation has been canceled. It will be finished at some point during the operation. return; - } else if (isExecuting()) { - DebugTool.logInfo("Canceling the presented keyboard."); + } - CancelInteraction cancelInteraction = new CancelInteraction(FunctionID.PERFORM_INTERACTION.getId(), cancelID); - cancelInteraction.setOnRPCResponseListener(new OnRPCResponseListener() { - @Override - public void onResponse(int correlationId, RPCResponse response) { - DebugTool.logInfo("Canceled the presented keyboard " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully")); - } + if (!isExecuting()) { + DebugTool.logInfo("Keyboard is not being presented so it can not be canceled."); + return; + } - @Override - public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("Error canceling the presented keyboard " + resultCode + " " + info); - }; - }); - if (internalInterface.get() != null){ - internalInterface.get().sendRPC(cancelInteraction); - } else { - DebugTool.logError("Internal interface null - could not send cancel interaction for keyboard"); + DebugTool.logInfo("Canceling the presented keyboard."); + CancelInteraction cancelInteraction = new CancelInteraction(FunctionID.PERFORM_INTERACTION.getId(), cancelID); + cancelInteraction.setOnRPCResponseListener(new OnRPCResponseListener() { + @Override + public void onResponse(int correlationId, RPCResponse response) { + DebugTool.logInfo("Canceled the presented keyboard " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully")); } + + @Override + public void onError(int correlationId, Result resultCode, String info){ + DebugTool.logError("Error canceling the presented keyboard " + resultCode + " " + info); + } + }); + if (internalInterface.get() != null){ + internalInterface.get().sendRPC(cancelInteraction); + } else { + DebugTool.logError("Internal interface null - could not send cancel interaction for keyboard"); } } |