diff options
author | orionlee <orionlee@yahoo.com> | 2019-01-06 13:07:49 -0800 |
---|---|---|
committer | orionlee <orionlee@yahoo.com> | 2019-02-27 14:52:34 -0800 |
commit | f0f862393777689148851e03877a01b46480183e (patch) | |
tree | daf05d2f98a6f692b3e3ec5fe4d987541cefb986 /core | |
parent | 584865ad180e54761d5e3a4b88a4f34f162f682e (diff) | |
download | AntennaPod-f0f862393777689148851e03877a01b46480183e.zip |
refactor stop PlaybackService codes - remove legacy dead codes
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 6c6213f2b..9fd752c10 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -466,30 +466,25 @@ public class PlaybackService extends MediaBrowserServiceCompat { return Service.START_NOT_STICKY; } - if ((flags & Service.START_FLAG_REDELIVERY) != 0) { - Log.d(TAG, "onStartCommand is a redelivered intent, calling stopForeground now."); - stopForeground(true); // TODO: [2716]-RemoveOptional legacy code from v0.9.8.1 that is no longer applicable, which used to return Service.START_REDELIVER_INTENT. See - } else { - if (keycode != -1) { - Log.d(TAG, "Received media button event"); - boolean handled = handleKeycode(keycode, true); - if (!handled) { - serviceManager.stopService(); // TODO: [2716]-RemoveOptional why is it added in the first place in v1.7.0? - return Service.START_NOT_STICKY; - } - } else if (!flavorHelper.castDisconnect(castDisconnect) && playable != null) { - boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM, - true); - boolean startWhenPrepared = intent.getBooleanExtra(EXTRA_START_WHEN_PREPARED, false); - boolean prepareImmediately = intent.getBooleanExtra(EXTRA_PREPARE_IMMEDIATELY, false); - sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); - //If the user asks to play External Media, the casting session, if on, should end. - flavorHelper.castDisconnect(playable instanceof ExternalMedia); - if (playable instanceof FeedMedia) { - playable = DBReader.getFeedMedia(((FeedMedia) playable).getId()); - } - mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately); + if (keycode != -1) { + Log.d(TAG, "Received media button event"); + boolean handled = handleKeycode(keycode, true); + if (!handled) { + serviceManager.stopService(); // TODO: [2716]-RemoveOptional why is it added in the first place in v1.7.0? + return Service.START_NOT_STICKY; + } + } else if (!flavorHelper.castDisconnect(castDisconnect) && playable != null) { + boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM, + true); + boolean startWhenPrepared = intent.getBooleanExtra(EXTRA_START_WHEN_PREPARED, false); + boolean prepareImmediately = intent.getBooleanExtra(EXTRA_PREPARE_IMMEDIATELY, false); + sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); + //If the user asks to play External Media, the casting session, if on, should end. + flavorHelper.castDisconnect(playable instanceof ExternalMedia); + if (playable instanceof FeedMedia) { + playable = DBReader.getFeedMedia(((FeedMedia) playable).getId()); } + mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately); } return Service.START_NOT_STICKY; |