fun updateDownload() { val ongoingDownloads: ArrayList<DownloadInfoRunnable> = getOngoingDownloads() if (!ongoingDownloads.isEmpty()) { updateProgress() } else { timer.cancel() timer.purge() stopSelf() mBuilder = null stopForeground(true) isStopped = true } }
Updates the download list and stops the service if it 's empty . If not , updates the progress in the Notification bar