From 469c06447b9e85bb25a43fbce8ca61ff2c399873 Mon Sep 17 00:00:00 2001 From: Robert Henigan Date: Thu, 16 Sep 2021 16:03:09 -0400 Subject: Update base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java Co-authored-by: Julian Kast --- .../managers/screen/choiceset/PreloadPresentChoicesOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java index 730f816c8..9ad04c1a2 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java @@ -605,7 +605,7 @@ class PreloadPresentChoicesOperation extends Task { choiceId = MAX_CHOICE_ID; return choiceId; } else { - //We haven't looped all the way around yet, so we'll just take the current number, then advance the item + // We haven't looped all the way around yet, so we'll just take the current number, then advance the item return choiceId++; } } -- cgit v1.2.1 From b7cf9555e188c84bb099d3f1480767c7277f7086 Mon Sep 17 00:00:00 2001 From: Robert Henigan Date: Thu, 16 Sep 2021 16:03:26 -0400 Subject: Update base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java Co-authored-by: Julian Kast --- .../managers/screen/choiceset/PreloadPresentChoicesOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java index 9ad04c1a2..43c669617 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java @@ -601,7 +601,7 @@ class PreloadPresentChoicesOperation extends Task { } } - //This *shouldn't* be possible + // This *shouldn't* be possible choiceId = MAX_CHOICE_ID; return choiceId; } else { -- cgit v1.2.1 From 0371f9f5bcbdcbecfd5fb643b9f8eba865de60c9 Mon Sep 17 00:00:00 2001 From: Robert Henigan Date: Thu, 16 Sep 2021 16:06:37 -0400 Subject: Apply suggestions from code review Co-authored-by: Julian Kast --- .../choiceset/PreloadPresentChoicesOperationTests.java | 1 - .../choiceset/PreloadPresentChoicesOperation.java | 17 ++++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperationTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperationTests.java index 2970fd2f0..0f3725f53 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperationTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperationTests.java @@ -41,7 +41,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; -import java.util.List; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertFalse; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java index 43c669617..4c9d5a3b5 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadPresentChoicesOperation.java @@ -40,7 +40,6 @@ import androidx.annotation.NonNull; import com.livio.taskmaster.Task; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.ISdl; -import com.smartdevicelink.managers.ManagerUtility; import static com.smartdevicelink.managers.ManagerUtility.WindowCapabilityUtility.hasImageFieldOfName; import static com.smartdevicelink.managers.ManagerUtility.WindowCapabilityUtility.hasTextFieldOfName; import com.smartdevicelink.managers.file.FileManager; @@ -96,7 +95,7 @@ class PreloadPresentChoicesOperation extends Task { private boolean choiceError = false; private HashSet loadedCells; private final ChoiceSet choiceSet; - //Start choiceId at 1 to ensure all HMIs handle it https://github.com/smartdevicelink/generic_hmi/commit/b292fbbec095b9ce11b520d47ec95b6fcff8e247 + // Start choiceId at 1 to ensure all HMIs handle it https://github.com/smartdevicelink/generic_hmi/commit/b292fbbec095b9ce11b520d47ec95b6fcff8e247 private static Integer choiceId = 1; private static Boolean reachedMaxIds = false; private static final int MAX_CHOICE_ID = 65535; @@ -547,12 +546,12 @@ class PreloadPresentChoicesOperation extends Task { Collections.sort(usedIds); ArrayList sortedUsedIds = (ArrayList) usedIds.clone(); - //Loop through the cells we need ids for. Get and assign those ids + // Loop through the cells we need ids for. Get and assign those ids for (int i = 0; i < cells.size(); i++) { int cellId = nextChoiceIdBasedOnUsedIds(sortedUsedIds); cells.get(i).setChoiceId(cellId); - //Insert the ids into the usedIds sorted array in the correct position + // Insert the ids into the usedIds sorted array in the correct position for (int j = 0; j < sortedUsedIds.size(); j++) { if (sortedUsedIds.get(j) > cellId) { sortedUsedIds.add(j, cellId); @@ -565,11 +564,11 @@ class PreloadPresentChoicesOperation extends Task { } } - //Find the next available choice is. Takes into account the loaded cells to ensure there are not duplicates + // Find the next available choice is. Takes into account the loaded cells to ensure there are not duplicates // @param usedIds The already loaded cell ids // @return The choice id between 0 - 65535, or Not Found if no cell ids were available private int nextChoiceIdBasedOnUsedIds(ArrayList usedIds) { - //Check if we are entirely full, or if we've advanced beyond the max value, loop back + // Check if we are entirely full, or if we've advanced beyond the max value, loop back if (choiceId == MAX_CHOICE_ID) { choiceId = 1; reachedMaxIds = true; @@ -584,18 +583,18 @@ class PreloadPresentChoicesOperation extends Task { return choiceId; } - //If the last value isn't the max value, just keep grabbing towards the max value + // If the last value isn't the max value, just keep grabbing towards the max value int lastUsedId = usedIds.get(usedIds.size() - 1); if (lastUsedId < MAX_CHOICE_ID) { choiceId = lastUsedId + 1; return choiceId; } - //All our easy options are gone. Find and grab an empty slot from within the sorted list + // All our easy options are gone. Find and grab an empty slot from within the sorted list for (int i = 0; i < usedIds.size(); i++) { int loopId = usedIds.get(i); if (i != loopId) { - //This slot is open because the cell id does not match an open sorted slot + // This slot is open because the cell id does not match an open sorted slot choiceId = i; return choiceId; } -- cgit v1.2.1