Skip to content

Commit

Permalink
PlayerHelper: fix sonar errors
Browse files Browse the repository at this point in the history
  • Loading branch information
neosis91 committed Feb 12, 2025
1 parent 27c3026 commit 756d923
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public void onAudioFocusChange(final int focusChange) {
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
onAudioFocusLossCanDuck();
break;
case AudioManager.AUDIOFOCUS_LOSS:
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
case AudioManager.AUDIOFOCUS_LOSS,
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
onAudioFocusLoss();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

public final class PlayerHelper {
private static final NumberFormat SPEED_FORMATTER = new DecimalFormat("0.##x");
private static final NumberFormat PITCH_FORMATTER = new DecimalFormat("##%");
private static final long MEGABYTE = 1024 * 1024L;
private static final Logger logger = Logger.getLogger(getClass().getName());
private static final Logger LOGGER = Logger.getLogger(getClass().getName());

@Retention(SOURCE)
@IntDef({AUTOPLAY_TYPE_ALWAYS, AUTOPLAY_TYPE_WIFI,
Expand Down Expand Up @@ -189,8 +188,8 @@ public static PlayQueue autoQueueOf(@NonNull final StreamInfo info,
return null;
}

if (relatedItems.get(0) instanceof StreamInfoItem firstItem &&
!urls.contains(firstItem.getUrl())) {
if (relatedItems.get(0) instanceof StreamInfoItem firstItem
&& !urls.contains(firstItem.getUrl())) {
return getAutoQueuedSinglePlayQueue(firstItem);
}

Expand All @@ -200,8 +199,8 @@ public static PlayQueue autoQueueOf(@NonNull final StreamInfo info,
.collect(Collectors.toList());

Collections.shuffle(autoQueueItems);
return autoQueueItems.isEmpty() ? null :
getAutoQueuedSinglePlayQueue(autoQueueItems.get(0));
return autoQueueItems.isEmpty() ? null
: getAutoQueuedSinglePlayQueue(autoQueueItems.get(0));
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -502,7 +501,7 @@ public static int retrieveSeekDurationFromPreferences(final Player player) {
try {
return Integer.parseInt(seekDurationString);
} catch (final NumberFormatException e) {
logger.info("Error during the conversion of the seek duration. : " + e.getMessage());
LOGGER.info("Error during the conversion of the seek duration. : " + e.getMessage());
return Integer.parseInt(defaultValue);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ private void onPlayQueueChanged(final PlayQueueEvent event) {

// Event specific action
switch (event.type()) {
case INIT:
case ERROR:
case INIT, ERROR:
maybeBlock();
case APPEND:
populateSources();
Expand Down Expand Up @@ -257,18 +256,18 @@ private void onPlayQueueChanged(final PlayQueueEvent event) {

// Loading and Syncing
switch (event.type()) {
case INIT: case REORDER: case ERROR: case SELECT:
case INIT, REORDER, ERROR, SELECT:
loadImmediate(); // low frequency, critical events
break;
case APPEND: case REMOVE: case MOVE: case RECOVERY:
case APPEND, REMOVE, MOVE, RECOVERY:
default:
loadDebounced(); // high frequency or noncritical events
break;
}

// update ui and notification
switch (event.type()) {
case APPEND: case REMOVE: case MOVE: case REORDER:
case APPEND, REMOVE, MOVE, REORDER:
playbackListener.onPlayQueueEdited();
}

Expand Down

0 comments on commit 756d923

Please sign in to comment.