Removed some unnecessary calls to startForeground
This commit is contained in:
parent
66ae028719
commit
52421d81f7
|
@ -192,10 +192,6 @@ public class DownloadService extends Service {
|
||||||
registerReceiver(cancelDownloadReceiver, cancelDownloadReceiverFilter);
|
registerReceiver(cancelDownloadReceiver, cancelDownloadReceiverFilter);
|
||||||
|
|
||||||
downloadCompletionThread.start();
|
downloadCompletionThread.start();
|
||||||
|
|
||||||
Notification notification = notificationManager.updateNotifications(
|
|
||||||
requester.getNumberOfDownloads(), downloads);
|
|
||||||
startForeground(R.id.notification_downloading, notification);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -551,20 +547,13 @@ public class DownloadService extends Service {
|
||||||
private void queryDownloads() {
|
private void queryDownloads() {
|
||||||
Log.d(TAG, numberOfDownloads.get() + " downloads left");
|
Log.d(TAG, numberOfDownloads.get() + " downloads left");
|
||||||
|
|
||||||
|
setupNotificationUpdaterIfNecessary();
|
||||||
|
notificationUpdater.run();
|
||||||
|
|
||||||
if (numberOfDownloads.get() <= 0 && DownloadRequester.getInstance().hasNoDownloads()) {
|
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);
|
stopForeground(true);
|
||||||
stopSelf();
|
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.
|
* Schedules the notification updater task if it hasn't been scheduled yet.
|
||||||
*/
|
*/
|
||||||
private void setupNotificationUpdater() {
|
private void setupNotificationUpdaterIfNecessary() {
|
||||||
if (notificationUpdater == null) {
|
if (notificationUpdater == null) {
|
||||||
Log.d(TAG, "Setting up notification updater");
|
Log.d(TAG, "Setting up notification updater");
|
||||||
notificationUpdater = new NotificationUpdater();
|
notificationUpdater = new NotificationUpdater();
|
||||||
|
|
Loading…
Reference in New Issue