diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2018-07-15 15:43:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-15 15:43:42 +0200 |
commit | fc2bd0e19b723c88355100d54f840c66e0cbd308 (patch) | |
tree | 6ae6eb1d509b642c7bb9ecd6b6510d75c6faf892 /core | |
parent | 740e202d7f1a2279c2b3e1fb5c3bdab9829818a3 (diff) | |
parent | 53a3b85272ad7ca68c2bfb2793b993b39a53986b (diff) | |
download | AntennaPod-fc2bd0e19b723c88355100d54f840c66e0cbd308.zip |
Merge pull request #2760 from ByteHamster/delete-item
Improve item deletion
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 24 |
1 files changed, 15 insertions, 9 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 91ae9da28..574e43faa 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 @@ -341,6 +341,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { public void onDestroy() { super.onDestroy(); Log.d(TAG, "Service is about to be destroyed"); + stopForeground(true); isRunning = false; started = false; currentMediaType = MediaType.UNKNOWN; @@ -363,6 +364,11 @@ public class PlaybackService extends MediaBrowserServiceCompat { mediaPlayer.shutdown(); taskManager.shutdown(); } + + private void stopService() { + stopForeground(true); + stopSelf(); + } @Override public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, Bundle rootHints) { @@ -458,7 +464,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { Playable playable = intent.getParcelableExtra(EXTRA_PLAYABLE); if (keycode == -1 && playable == null && !castDisconnect) { Log.e(TAG, "PlaybackService was started with no arguments"); - stopSelf(); + stopService(); return Service.START_NOT_STICKY; } @@ -470,7 +476,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { Log.d(TAG, "Received media button event"); boolean handled = handleKeycode(keycode, true); if (!handled) { - stopSelf(); + stopService(); return Service.START_NOT_STICKY; } } else if (!flavorHelper.castDisconnect(castDisconnect) && playable != null) { @@ -680,7 +686,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { case STOPPED: //writePlaybackPreferencesNoMediaPlaying(); - //stopSelf(); + //stopService(); break; case PLAYING: @@ -697,7 +703,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { case ERROR: writePlaybackPreferencesNoMediaPlaying(); - stopSelf(); + stopService(); break; } @@ -710,7 +716,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { @Override public void shouldStop() { - stopSelf(); + stopService(); } @Override @@ -759,7 +765,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { } sendNotificationBroadcast(NOTIFICATION_TYPE_ERROR, what); writePlaybackPreferencesNoMediaPlaying(); - stopSelf(); + stopService(); return true; } @@ -1213,7 +1219,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { if (playable == null) { Log.d(TAG, "setupNotification: playable is null"); if (!started) { - stopSelf(); + stopService(); } return; } @@ -1227,7 +1233,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { if (mediaPlayer == null) { Log.d(TAG, "notificationSetupTask: mediaPlayer is null"); if (!started) { - stopSelf(); + stopService(); } return; } @@ -1548,7 +1554,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { @Override public void onReceive(Context context, Intent intent) { if (TextUtils.equals(intent.getAction(), ACTION_SHUTDOWN_PLAYBACK_SERVICE)) { - stopSelf(); + stopService(); } } |