From d84312b631a8ae5676a077b17741b1fc4fe9136d Mon Sep 17 00:00:00 2001 From: Matteo Hausner Date: Wed, 6 Dec 2023 23:19:38 +0100 Subject: [PATCH] Fix new IDEA insepections --- .../de/bwravencl/controllerbuddy/gui/EditActionsDialog.java | 2 +- src/main/java/de/bwravencl/controllerbuddy/gui/Main.java | 4 ++-- .../de/bwravencl/controllerbuddy/gui/OpenVrOverlay.java | 6 +----- src/main/java/de/bwravencl/controllerbuddy/input/Input.java | 4 ++-- .../controllerbuddy/input/action/ButtonToModeAction.java | 2 +- .../bwravencl/controllerbuddy/input/driver/EvdevDriver.java | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/bwravencl/controllerbuddy/gui/EditActionsDialog.java b/src/main/java/de/bwravencl/controllerbuddy/gui/EditActionsDialog.java index cc6dd348..02e9a295 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/gui/EditActionsDialog.java +++ b/src/main/java/de/bwravencl/controllerbuddy/gui/EditActionsDialog.java @@ -189,7 +189,7 @@ public EditActionsDialog( setTitle(MessageFormat.format(Main.strings.getString("EDIT_ACTIONS_DIALOG_TITLE_COMPONENT_EDITOR"), name)); final var modes = unsavedProfile.getModes(); - selectedMode = modes.get(0); + selectedMode = modes.getFirst(); GuiUtils.addModePanel(getContentPane(), modes, new AbstractAction() { @Serial diff --git a/src/main/java/de/bwravencl/controllerbuddy/gui/Main.java b/src/main/java/de/bwravencl/controllerbuddy/gui/Main.java index fd046e7b..b01b5dfd 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/gui/Main.java +++ b/src/main/java/de/bwravencl/controllerbuddy/gui/Main.java @@ -963,7 +963,7 @@ public void windowOpened(final WindowEvent e) { }, () -> { log.log(Level.INFO, "Previously used controller is not present"); - setSelectedController(presentControllers.get(0)); + setSelectedController(presentControllers.getFirst()); }); } } @@ -2209,7 +2209,7 @@ private void onControllersChanged(final List presentControllers, if (!controllerConnected) { selectedController = null; } else if (selectedController == null) { - setSelectedControllerAndUpdateInput(presentControllers.get(0), null); + setSelectedControllerAndUpdateInput(presentControllers.getFirst(), null); updateTitleAndTooltip(); if (isAutoRestartOutput()) { diff --git a/src/main/java/de/bwravencl/controllerbuddy/gui/OpenVrOverlay.java b/src/main/java/de/bwravencl/controllerbuddy/gui/OpenVrOverlay.java index 017072ad..ae012acd 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/gui/OpenVrOverlay.java +++ b/src/main/java/de/bwravencl/controllerbuddy/gui/OpenVrOverlay.java @@ -407,11 +407,7 @@ private void updateOverlay(final long overlayHandle, final Frame frame) { checkOverlayError(VROverlay.VROverlay_ShowOverlay(overlayHandle)); if (VROverlay.VROverlay_IsOverlayVisible(overlayHandle)) { - var textureData = textureDataCache.get(overlayHandle); - if (textureData == null) { - textureData = new TextureData(); - textureDataCache.put(overlayHandle, textureData); - } + final var textureData = textureDataCache.computeIfAbsent(overlayHandle, k -> new TextureData()); final var imageResized = textureData.image == null || textureData.image.getWidth() != frame.getWidth() diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/Input.java b/src/main/java/de/bwravencl/controllerbuddy/input/Input.java index 61830dc9..7c1b9dd0 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/Input.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/Input.java @@ -469,7 +469,7 @@ public boolean poll() { } if (actions == null) { - actions = modes.get(0).getAxisToActionsMap().get(axis); + actions = modes.getFirst().getAxisToActionsMap().get(axis); } if (actions != null) { @@ -497,7 +497,7 @@ public boolean poll() { } if (actions == null) { - actions = modes.get(0).getButtonToActionsMap().get(button); + actions = modes.getFirst().getButtonToActionsMap().get(button); } if (actions != null) { diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java index c5c0b78c..3f5b5473 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java @@ -122,7 +122,7 @@ private void deactivateMode(final Input input, final Profile profile) { if (previousButtonToModeAction != null) { previousMode = previousButtonToModeAction.getMode(input); } else { - previousMode = profile.getModes().get(0); + previousMode = profile.getModes().getFirst(); } final var activeMode = profile.getActiveMode(); diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/driver/EvdevDriver.java b/src/main/java/de/bwravencl/controllerbuddy/input/driver/EvdevDriver.java index 9f67ce7a..21257acc 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/driver/EvdevDriver.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/driver/EvdevDriver.java @@ -288,7 +288,7 @@ public Driver getIfAvailable( } try { - return new EvdevDriver(input, selectedController, evdevInfos.get(0)); + return new EvdevDriver(input, selectedController, evdevInfos.getFirst()); } catch (final IOException e) { log.log(Level.SEVERE, e.getMessage(), e); }