From cb70aeb3cfe1cdf81937ee98c79cee324024048a Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 6 May 2018 19:15:40 +0200 Subject: Code style improvements --- .../antennapod/activity/MediaplayerActivity.java | 11 +++-- .../adapter/DefaultActionButtonCallback.java | 8 ++-- .../fragment/ExternalPlayerFragment.java | 52 +++++++++++----------- 3 files changed, 34 insertions(+), 37 deletions(-) (limited to 'app/src/main/java/de') diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index de65ca406..701f9b79a 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -619,12 +619,11 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements public void onEventMainThread(ServiceEvent event) { Log.d(TAG, "onEvent(" + event + ")"); - switch(event.action) { - case SERVICE_STARTED: - if (controller != null) { - controller.init(); - } - break; + if (event.action == ServiceEvent.Action.SERVICE_STARTED) { + if (controller != null) { + controller.init(); + } + } } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java index 3f8f871c2..a531c86ed 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java @@ -80,15 +80,13 @@ public class DefaultActionButtonCallback implements ActionButtonCallback { Toast.makeText(context, R.string.download_canceled_msg, Toast.LENGTH_LONG).show(); } } else { // media is downloaded - if (item.hasMedia() && item.getMedia().isCurrentlyPlaying()) { + if (media.isCurrentlyPlaying()) { PlaybackService.startIfNotRunning(context, media, true, false); context.sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE)); - } - else if (item.hasMedia() && item.getMedia().isCurrentlyPaused()) { + } else if (media.isCurrentlyPaused()) { PlaybackService.startIfNotRunning(context, media, true, false); context.sendBroadcast(new Intent(PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE)); - } - else { + } else { DBTasks.playMedia(context, media, false, true, false); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java index 27df29f9f..b072aeaf2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -168,35 +168,35 @@ public class ExternalPlayerFragment extends Fragment { private boolean loadMediaInfo() { Log.d(TAG, "Loading media info"); - if (controller != null) { - Playable media = controller.getMedia(); - if (media != null) { - txtvTitle.setText(media.getEpisodeTitle()); - mFeedName.setText(media.getFeedTitle()); - onPositionObserverUpdate(); - - Glide.with(getActivity()) - .load(media.getImageLocation()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() - .into(imgvCover); - - fragmentLayout.setVisibility(View.VISIBLE); - if (controller.isPlayingVideoLocally()) { - butPlay.setVisibility(View.GONE); - } else { - butPlay.setVisibility(View.VISIBLE); - } - return true; + if (controller == null) { + Log.w(TAG, "loadMediaInfo was called while PlaybackController was null!"); + return false; + } + + Playable media = controller.getMedia(); + if (media != null) { + txtvTitle.setText(media.getEpisodeTitle()); + mFeedName.setText(media.getFeedTitle()); + onPositionObserverUpdate(); + + Glide.with(getActivity()) + .load(media.getImageLocation()) + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate() + .into(imgvCover); + + fragmentLayout.setVisibility(View.VISIBLE); + if (controller.isPlayingVideoLocally()) { + butPlay.setVisibility(View.GONE); } else { - Log.w(TAG, "loadMediaInfo was called while the media object of playbackService was null!"); - return false; + butPlay.setVisibility(View.VISIBLE); } + return true; } else { - Log.w(TAG, "loadMediaInfo was called while playbackService was null!"); + Log.w(TAG, "loadMediaInfo was called while the media object of playbackService was null!"); return false; } } -- cgit v1.2.3