diff options
author | ByteHamster <info@bytehamster.com> | 2021-02-06 12:05:10 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-02-15 11:28:03 +0100 |
commit | 52421d81f73277557a2ba2ad097379f105213d98 (patch) | |
tree | 96045b8bb052e82cad5812fb7f43e0c23edc0716 /core | |
parent | 66ae028719995aea5d39128ff44b026567fc34a6 (diff) | |
download | AntennaPod-52421d81f73277557a2ba2ad097379f105213d98.zip |
Removed some unnecessary calls to startForeground
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index 025088273..bc696f444 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -192,10 +192,6 @@ public class DownloadService extends Service { registerReceiver(cancelDownloadReceiver, cancelDownloadReceiverFilter); downloadCompletionThread.start(); - - Notification notification = notificationManager.updateNotifications( - requester.getNumberOfDownloads(), downloads); - startForeground(R.id.notification_downloading, notification); } @Override @@ -551,20 +547,13 @@ public class DownloadService extends Service { private void queryDownloads() { Log.d(TAG, numberOfDownloads.get() + " downloads left"); + setupNotificationUpdaterIfNecessary(); + notificationUpdater.run(); + if (numberOfDownloads.get() <= 0 && DownloadRequester.getInstance().hasNoDownloads()) { - Log.d(TAG, "Number of downloads is " + numberOfDownloads.get() + ", attempting shutdown"); + Log.d(TAG, "Attempting shutdown"); stopForeground(true); stopSelf(); - if (notificationUpdater != null) { - notificationUpdater.run(); - } else { - Log.d(TAG, "Skipping notification update"); - } - } else { - setupNotificationUpdater(); - Notification notification = notificationManager.updateNotifications( - requester.getNumberOfDownloads(), downloads); - startForeground(R.id.notification_downloading, notification); } } @@ -617,7 +606,7 @@ public class DownloadService extends Service { /** * Schedules the notification updater task if it hasn't been scheduled yet. */ - private void setupNotificationUpdater() { + private void setupNotificationUpdaterIfNecessary() { if (notificationUpdater == null) { Log.d(TAG, "Setting up notification updater"); notificationUpdater = new NotificationUpdater(); |