diff options
author | NicoleYarroch <nicole@livio.io> | 2019-08-21 11:42:54 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-08-21 11:42:54 -0400 |
commit | 814afb9c8cde62aafe45e1331471c0add7b9c9a5 (patch) | |
tree | 6a0936c067595b6ec59113bf6427d79581a0510e /base/src/main/java/com/smartdevicelink/managers/screen/choiceset | |
parent | 6e38a4b105f723bd18abf4615102485f8160baa2 (diff) | |
download | sdl_android-814afb9c8cde62aafe45e1331471c0add7b9c9a5.tar.gz |
Refactored Thread.currentThread().isInterrupted()
Diffstat (limited to 'base/src/main/java/com/smartdevicelink/managers/screen/choiceset')
3 files changed, 19 insertions, 9 deletions
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/AsynchronousOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/AsynchronousOperation.java index bf418270c..f3edd6d2c 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/AsynchronousOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/AsynchronousOperation.java @@ -48,12 +48,17 @@ class AsynchronousOperation implements Runnable { @Override public void run() { DebugTool.logInfo("Starting operation: " + toString()); - if (Thread.currentThread().isInterrupted()) { + if (isCancelled()) { finished = true; DebugTool.logInfo("Operation was cancelled: " + toString()); return; } + try { + + } catch (InterruptedException e) { + } + executing = true; } @@ -75,6 +80,11 @@ class AsynchronousOperation implements Runnable { return finished; } + public Boolean isCancelled() { + return Thread.currentThread().isInterrupted(); + } + + @Override public String toString() { return "Executing: " + executing + ", finished: " + finished + "."; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java index fb33cb477..40672a2df 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java @@ -106,7 +106,7 @@ class PresentChoiceSetOperation extends AsynchronousOperation { } private void start(){ - if (Thread.currentThread().isInterrupted()) { + if (isCancelled()) { finishOperation(); return; } @@ -120,7 +120,7 @@ class PresentChoiceSetOperation extends AsynchronousOperation { updateKeyboardProperties(new CompletionListener() { @Override public void onComplete(boolean success) { - if (Thread.currentThread().isInterrupted()) { + if (isCancelled()) { finishOperation(); return; } @@ -237,7 +237,7 @@ class PresentChoiceSetOperation extends AsynchronousOperation { if (isFinished()) { DebugTool.logInfo("This operation has already finished so it can not be canceled."); return; - } else if (Thread.currentThread().isInterrupted()) { + } else if (isCancelled()) { DebugTool.logInfo("This operation has already been canceled. It will be finished at some point during the operation."); return; } else if (isExecuting()) { @@ -327,7 +327,7 @@ class PresentChoiceSetOperation extends AsynchronousOperation { keyboardRPCListener = new OnRPCNotificationListener() { @Override public void onNotified(RPCNotification notification) { - if (Thread.currentThread().isInterrupted()) { + if (isCancelled()) { finishOperation(); return; } 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 9346725fb..188016129 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 @@ -92,7 +92,7 @@ class PresentKeyboardOperation extends AsynchronousOperation { private void start(){ DebugTool.logInfo("Choice Operation: Executing present keyboard operation"); - if (Thread.currentThread().isInterrupted()) { + if (isCancelled()) { finishOperation(); return; } @@ -105,7 +105,7 @@ class PresentKeyboardOperation extends AsynchronousOperation { updateKeyboardProperties(new CompletionListener() { @Override public void onComplete(boolean success) { - if (Thread.currentThread().isInterrupted()) { + if (isCancelled()) { finishOperation(); return; } @@ -149,7 +149,7 @@ class PresentKeyboardOperation extends AsynchronousOperation { if (isFinished()) { DebugTool.logInfo("This operation has already finished so it can not be canceled."); return; - } else if (Thread.currentThread().isInterrupted()) { + } else if (isCancelled()) { DebugTool.logInfo("This operation has already been canceled. It will be finished at some point during the operation."); return; } else if (isExecuting()) { @@ -275,7 +275,7 @@ class PresentKeyboardOperation extends AsynchronousOperation { keyboardRPCListener = new OnRPCNotificationListener() { @Override public void onNotified(RPCNotification notification) { - if (Thread.currentThread().isInterrupted()) { + if (isCancelled()) { finishOperation(); return; } |