mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-25 10:24:31 +01:00
Notification Revival Fix
This commit is contained in:
parent
e4b47d871a
commit
9525c40e8c
@ -104,6 +104,7 @@ class ForegroundService : LifecycleService() {
|
||||
@SuppressLint("WakelockTimeout")
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
super.onStartCommand(intent, flags, startId)
|
||||
downloadService.reviveIfClosed()
|
||||
// Send a notification that service is started
|
||||
Log.i(TAG, "Foreground Service Started.")
|
||||
startForeground(NOTIFICATION_ID, createNotification())
|
||||
@ -135,6 +136,7 @@ class ForegroundService : LifecycleService() {
|
||||
* Function To Download All Tracks Available in a List
|
||||
**/
|
||||
fun downloadAllTracks(trackList: List<TrackDetails>) {
|
||||
downloadService.reviveIfClosed()
|
||||
trackList.size.also { size ->
|
||||
total += size
|
||||
isSingleDownload = (size == 1)
|
||||
|
@ -84,6 +84,12 @@ class ParallelExecutor(
|
||||
coroutineContext.cancel(cause)
|
||||
}
|
||||
|
||||
fun reviveIfClosed() {
|
||||
if (!service.isActive) {
|
||||
closeAndReInit()
|
||||
}
|
||||
}
|
||||
|
||||
fun closeAndReInit(newConcurrentOperationLimit: Int = 4) {
|
||||
// Close Everything
|
||||
close()
|
||||
@ -94,6 +100,7 @@ class ParallelExecutor(
|
||||
killQueue = Channel(Channel.UNLIMITED)
|
||||
operationQueue = Channel(Channel.RENDEZVOUS)
|
||||
concurrentOperationLimit = atomic(newConcurrentOperationLimit)
|
||||
startOrStopProcessors(expectedCount = this.concurrentOperationLimit.value, actualCount = 0)
|
||||
}
|
||||
|
||||
private fun CoroutineScope.launchProcessor() = launch {
|
||||
|
Loading…
Reference in New Issue
Block a user