From 1e336ac0f8dd7ad74f576f2ce478222eaab26c1b Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 1 Nov 2022 11:58:48 +0100 Subject: [PATCH] No need to have a virtual method that is only used in one single instance --- .../activity/VideoplayerActivity.java | 28 +++++++------------ .../util/playback/PlaybackController.java | 25 ++--------------- 2 files changed, 12 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java index 8c2d7b314..b96b18e85 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -190,6 +190,16 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar. @Override protected void updatePlayButtonShowsPlay(boolean showPlay) { viewBinding.playButton.setIsShowPlay(showPlay); + if (showPlay) { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + setupVideoAspectRatio(); + if (videoSurfaceCreated && controller != null) { + Log.d(TAG, "Videosurface already created, setting videosurface now"); + controller.setVideoSurface(viewBinding.videoView.getHolder()); + } + } } @Override @@ -197,28 +207,10 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar. VideoplayerActivity.this.loadMediaInfo(); } - @Override - public void onAwaitingVideoSurface() { - setupVideoAspectRatio(); - if (videoSurfaceCreated && controller != null) { - Log.d(TAG, "Videosurface already created, setting videosurface now"); - controller.setVideoSurface(viewBinding.videoView.getHolder()); - } - } - @Override public void onPlaybackEnd() { finish(); } - - @Override - protected void setScreenOn(boolean enable) { - if (enable) { - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } else { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } - } }; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java index 5b6530850..80795a7cd 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java @@ -235,17 +235,7 @@ public abstract class PlaybackController { Log.d(TAG, "status: " + status.toString()); checkMediaInfoLoaded(); switch (status) { - case PAUSED: - updatePlayButtonShowsPlay(true); - if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) { - setScreenOn(false); - } - break; case PLAYING: - if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) { - onAwaitingVideoSurface(); - setScreenOn(true); - } updatePlayButtonShowsPlay(false); break; case PREPARING: @@ -253,7 +243,8 @@ public abstract class PlaybackController { updatePlayButtonShowsPlay(!playbackService.isStartWhenPrepared()); } break; - case PREPARED: + case PAUSED: + case PREPARED: // Fall-through case STOPPED: // Fall-through case INITIALIZED: // Fall-through updatePlayButtonShowsPlay(true); @@ -277,8 +268,6 @@ public abstract class PlaybackController { public abstract void loadMediaInfo(); - public void onAwaitingVideoSurface() {} - /** * Called when connection to playback service has been established or * information has to be refreshed @@ -300,16 +289,6 @@ public abstract class PlaybackController { } } - /** - * Should be implemented by classes that show a video. The default implementation - * does nothing - * - * @param enable True if the screen should be kept on, false otherwise - */ - protected void setScreenOn(boolean enable) { - - } - public void playPause() { if (playbackService == null) { new PlaybackServiceStarter(activity, media).start();