summaryrefslogtreecommitdiff
path: root/playback
diff options
context:
space:
mode:
authorTaco <SkytkRSfan3895@gmail.com>2024-04-05 20:28:36 +0300
committerGitHub <noreply@github.com>2024-04-05 19:28:36 +0200
commitb6a4049ff4a792cbed826320064ccca72fc3e6e5 (patch)
tree83b8b52a1954c2b1374ee5b691c7bd0e00009c71 /playback
parent92ab575b150ab49ca85e0ac994558142e49c9e68 (diff)
downloadAntennaPod-b6a4049ff4a792cbed826320064ccca72fc3e6e5.zip
Spotbugs cleanup (#6968)
Remove unused SpotBugs rules. Fix URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD, ICAST_INTEGER_MULTIPLY_CAST_TO_LONG, NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION, OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE
Diffstat (limited to 'playback')
-rw-r--r--playback/base/src/main/java/de/danoeh/antennapod/playback/base/PlaybackServiceMediaPlayer.java22
-rw-r--r--playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java8
-rw-r--r--playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java39
3 files changed, 43 insertions, 26 deletions
diff --git a/playback/base/src/main/java/de/danoeh/antennapod/playback/base/PlaybackServiceMediaPlayer.java b/playback/base/src/main/java/de/danoeh/antennapod/playback/base/PlaybackServiceMediaPlayer.java
index 39ee99884..250ef0575 100644
--- a/playback/base/src/main/java/de/danoeh/antennapod/playback/base/PlaybackServiceMediaPlayer.java
+++ b/playback/base/src/main/java/de/danoeh/antennapod/playback/base/PlaybackServiceMediaPlayer.java
@@ -360,14 +360,30 @@ public abstract class PlaybackServiceMediaPlayer {
* Holds information about a PSMP object.
*/
public static class PSMPInfo {
- public final PlayerStatus oldPlayerStatus;
- public PlayerStatus playerStatus;
- public Playable playable;
+ private final PlayerStatus oldPlayerStatus;
+ private final PlayerStatus playerStatus;
+ private Playable playable;
public PSMPInfo(PlayerStatus oldPlayerStatus, PlayerStatus playerStatus, Playable playable) {
this.oldPlayerStatus = oldPlayerStatus;
this.playerStatus = playerStatus;
this.playable = playable;
}
+
+ public PlayerStatus getOldPlayerStatus() {
+ return oldPlayerStatus;
+ }
+
+ public PlayerStatus getPlayerStatus() {
+ return playerStatus;
+ }
+
+ public Playable getPlayable() {
+ return playable;
+ }
+
+ public void setPlayable(final Playable newPlayable) {
+ playable = newPlayable;
+ }
}
}
diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java
index 50647b5dd..f6df19c61 100644
--- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java
+++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java
@@ -182,8 +182,8 @@ public abstract class PlaybackController {
Log.d(TAG, "Received statusUpdate Intent.");
if (playbackService != null) {
PlaybackServiceMediaPlayer.PSMPInfo info = playbackService.getPSMPInfo();
- status = info.playerStatus;
- media = info.playable;
+ status = info.getPlayerStatus();
+ media = info.getPlayable();
handleStatus();
} else {
Log.w(TAG, "Couldn't receive status update: playbackService was null");
@@ -275,8 +275,8 @@ public abstract class PlaybackController {
Log.d(TAG, "Querying service info");
if (playbackService != null) {
PlaybackServiceMediaPlayer.PSMPInfo info = playbackService.getPSMPInfo();
- status = info.playerStatus;
- media = info.playable;
+ status = info.getPlayerStatus();
+ media = info.getPlayable();
// make sure that new media is loaded if it's available
mediaInfoLoaded = false;
diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java
index 8932a36d2..f17a73a77 100644
--- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java
+++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java
@@ -646,7 +646,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
private boolean handleKeycode(int keycode, boolean notificationButton) {
Log.d(TAG, "Handling keycode: " + keycode);
final PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
- final PlayerStatus status = info.playerStatus;
+ final PlayerStatus status = info.getPlayerStatus();
switch (keycode) {
case KeyEvent.KEYCODE_HEADSETHOOK:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
@@ -724,7 +724,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
return true;
default:
Log.d(TAG, "Unhandled key code: " + keycode);
- if (info.playable != null && info.playerStatus == PlayerStatus.PLAYING) { // only notify the user about an unknown key event if it is actually doing something
+ // only notify the user about an unknown key event if it is actually doing something
+ if (info.getPlayable() != null && info.getPlayerStatus() == PlayerStatus.PLAYING) {
String message = String.format(getResources().getString(R.string.unknown_media_key), keycode);
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
@@ -813,22 +814,22 @@ public class PlaybackService extends MediaBrowserServiceCompat {
currentMediaType = MediaType.UNKNOWN;
}
- updateMediaSession(newInfo.playerStatus);
- switch (newInfo.playerStatus) {
+ updateMediaSession(newInfo.getPlayerStatus());
+ switch (newInfo.getPlayerStatus()) {
case INITIALIZED:
- if (mediaPlayer.getPSMPInfo().playable != null) {
- PlaybackPreferences.writeMediaPlaying(mediaPlayer.getPSMPInfo().playable);
+ if (mediaPlayer.getPSMPInfo().getPlayable() != null) {
+ PlaybackPreferences.writeMediaPlaying(mediaPlayer.getPSMPInfo().getPlayable());
}
- updateNotificationAndMediaSession(newInfo.playable);
+ updateNotificationAndMediaSession(newInfo.getPlayable());
break;
case PREPARED:
- if (mediaPlayer.getPSMPInfo().playable != null) {
- PlaybackPreferences.writeMediaPlaying(mediaPlayer.getPSMPInfo().playable);
+ if (mediaPlayer.getPSMPInfo().getPlayable() != null) {
+ PlaybackPreferences.writeMediaPlaying(mediaPlayer.getPSMPInfo().getPlayable());
}
- taskManager.startChapterLoader(newInfo.playable);
+ taskManager.startChapterLoader(newInfo.getPlayable());
break;
case PAUSED:
- updateNotificationAndMediaSession(newInfo.playable);
+ updateNotificationAndMediaSession(newInfo.getPlayable());
PlaybackPreferences.setCurrentPlayerStatus(PlaybackPreferences.PLAYER_STATUS_PAUSED);
if (!isCasting) {
stateManager.stopForeground(!UserPreferences.isPersistNotify());
@@ -843,7 +844,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
PlaybackPreferences.setCurrentPlayerStatus(PlaybackPreferences.PLAYER_STATUS_PLAYING);
saveCurrentPosition(true, null, Playable.INVALID_TIME);
recreateMediaSessionIfNeeded();
- updateNotificationAndMediaSession(newInfo.playable);
+ updateNotificationAndMediaSession(newInfo.getPlayable());
setupPositionObserver();
stateManager.validStartCommandWasReceived();
stateManager.startForeground(R.id.notification_playing, notificationBuilder.build());
@@ -858,7 +859,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
autoEnableByTime = SleepTimerPreferences.isInTimeRange(fromSetting, toSetting, currentHour);
}
- if (newInfo.oldPlayerStatus != null && newInfo.oldPlayerStatus != PlayerStatus.SEEKING
+ if (newInfo.getOldPlayerStatus() != null && newInfo.getOldPlayerStatus() != PlayerStatus.SEEKING
&& SleepTimerPreferences.autoEnable() && autoEnableByTime && !sleepTimerActive()) {
setSleepTimer(SleepTimerPreferences.timerMillis());
EventBus.getDefault().post(new MessageEvent(getString(R.string.sleep_timer_enabled_label),
@@ -1460,19 +1461,19 @@ public class PlaybackService extends MediaBrowserServiceCompat {
private void bluetoothNotifyChange(PlaybackServiceMediaPlayer.PSMPInfo info, String whatChanged) {
boolean isPlaying = false;
- if (info.playerStatus == PlayerStatus.PLAYING) {
+ if (info.getPlayerStatus() == PlayerStatus.PLAYING) {
isPlaying = true;
}
- if (info.playable != null) {
+ if (info.getPlayable() != null) {
Intent i = new Intent(whatChanged);
i.putExtra("id", 1L);
i.putExtra("artist", "");
- i.putExtra("album", info.playable.getFeedTitle());
- i.putExtra("track", info.playable.getEpisodeTitle());
+ i.putExtra("album", info.getPlayable().getFeedTitle());
+ i.putExtra("track", info.getPlayable().getEpisodeTitle());
i.putExtra("playing", isPlaying);
- i.putExtra("duration", (long) info.playable.getDuration());
- i.putExtra("position", (long) info.playable.getPosition());
+ i.putExtra("duration", (long) info.getPlayable().getDuration());
+ i.putExtra("position", (long) info.getPlayable().getPosition());
sendBroadcast(i);
}
}