diff options
author | NicoleYarroch <nicole@livio.io> | 2019-08-02 16:29:53 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-08-02 16:29:53 -0400 |
commit | 1e9e5fe5faa5ca187fde8c2b2bd8c7496eb5bb61 (patch) | |
tree | a70f63d1ee141c59d2782b3f52b2bc13368d5df0 | |
parent | 0223edf280af353308c861501ebaf768683a0803 (diff) | |
download | sdl_android-1e9e5fe5faa5ca187fde8c2b2bd8c7496eb5bb61.tar.gz |
Added logic to dismiss keyboard
-rw-r--r-- | base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java | 24 |
1 files changed, 8 insertions, 16 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 9d8daa108..8e29e8d19 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 @@ -94,6 +94,8 @@ abstract class BaseChoiceSetManager extends BaseSubManager { LinkedBlockingQueue<Runnable> operationQueue; Future pendingPresentOperation; + PresentKeyboardOperation currentlyPresentedKeyboardOperation; + int nextChoiceId; int nextCancelId; final int choiceCellIdMin = 1; @@ -119,6 +121,8 @@ abstract class BaseChoiceSetManager extends BaseSubManager { operationQueue = new LinkedBlockingQueue<>(); executor = new PausableThreadPoolExecutor(1, Runtime.getRuntime().availableProcessors(), 10, TimeUnit.SECONDS, operationQueue); executor.pause(); // pause until HMI ready + + currentlyPresentedKeyboardOperation = null; } @Override @@ -396,26 +400,14 @@ abstract class BaseChoiceSetManager extends BaseSubManager { // Present a keyboard with the choice set that we used to test VR's optional state DebugTool.logInfo("Presenting Keyboard - Choice Set Manager"); PresentKeyboardOperation keyboardOp = new PresentKeyboardOperation(internalInterface, keyboardConfiguration, initialText, customKeyboardConfig, listener, nextCancelId++); + currentlyPresentedKeyboardOperation = keyboardOp; pendingPresentOperation = executor.submit(keyboardOp); } public void dismissKeyboard() { - Thread thread = Thread.currentThread(); - if (Thread.currentThread().getClass().equals(PresentKeyboardOperation.class)) { - DebugTool.logInfo("Got something - Choice Set Manager"); - } - - if (pendingPresentOperation instanceof PresentKeyboardOperation) { - DebugTool.logInfo("Got something - Choice Set Manager"); - } - - if (pendingPresentOperation.getClass().equals(PresentKeyboardOperation.class)) { - DebugTool.logInfo("Got something - Choice Set Manager"); - } - - for (Runnable operation : operationQueue){ - if (!(operation instanceof PresentKeyboardOperation)){ continue; } - ((PresentKeyboardOperation) operation).cancelKeyboard(); + if (currentlyPresentedKeyboardOperation != null && currentlyPresentedKeyboardOperation.isExecuting()) { + // If the keyboard is currently presented, cancel it. Otherwise it will be ignored. + currentlyPresentedKeyboardOperation.cancelKeyboard(); } } |