diff options
author | orionlee <orionlee@yahoo.com> | 2019-01-06 13:35:00 -0800 |
---|---|---|
committer | orionlee <orionlee@yahoo.com> | 2019-02-27 14:52:34 -0800 |
commit | 221cd4b480125566122af28893db1428d6db4cc7 (patch) | |
tree | 0e47fde238008cae4342e1df30eb9fc925a1affe /core/src/main/java | |
parent | f0f862393777689148851e03877a01b46480183e (diff) | |
download | AntennaPod-221cd4b480125566122af28893db1428d6db4cc7.zip |
refactor stop PlaybackService setupNotification() - extract common
code as private helper.
Diffstat (limited to 'core/src/main/java')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 17 |
1 files changed, 9 insertions, 8 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 9fd752c10..ddc52028d 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 @@ -1336,29 +1336,30 @@ public class PlaybackService extends MediaBrowserServiceCompat { Log.v(TAG, "DBG - notificationSetupTask: make service foreground"); startForeground(NOTIFICATION_ID, notification); } else if (playerStatus == PlayerStatus.PAUSED) { - // TODO: logic originally in mediaPlayerCallback case PAUSED. if (treatPauseAsStop) { stopForeground(true); } else if ((UserPreferences.isPersistNotify() || isCasting) && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // do not remove notification on pause based on user pref and whether android version supports expanded notifications // Change [Play] button to [Pause] - // TODO LATER: logic same as outer else clause: setupNotification(info) - stopForeground(false); - NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - mNotificationManager.notify(NOTIFICATION_ID, notification); + leaveNotificationAsBackground(notification); } else if (!UserPreferences.isPersistNotify() && !isCasting) { // remove notification on pause stopForeground(true); } } else { - stopForeground(false); - NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - mNotificationManager.notify(NOTIFICATION_ID, notification); + leaveNotificationAsBackground(notification); } Log.d(TAG, "Notification set up"); } } + + private void leaveNotificationAsBackground(@NonNull Notification notification) { + stopForeground(false); + NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + mNotificationManager.notify(NOTIFICATION_ID, notification); + } + }; notificationSetupThread = new Thread(notificationSetupTask); notificationSetupThread.start(); |