mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-12-22 20:57:54 +01:00
Refactoring
This commit is contained in:
parent
59068c6c8b
commit
bfb0f800ad
@ -81,6 +81,7 @@ class ForegroundService : LifecycleService() {
|
||||
inner class DownloadServiceBinder : Binder() {
|
||||
val service get() = this@ForegroundService
|
||||
}
|
||||
|
||||
private val myBinder: IBinder = DownloadServiceBinder()
|
||||
|
||||
override fun onBind(intent: Intent): IBinder {
|
||||
@ -304,12 +305,16 @@ class ForegroundService : LifecycleService() {
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (isFinished) { killService() }
|
||||
if (isFinished) {
|
||||
killService()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||
super.onTaskRemoved(rootIntent)
|
||||
if (isFinished) { killService() }
|
||||
if (isFinished) {
|
||||
killService()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -22,12 +22,14 @@ import co.touchlab.kermit.Kermit
|
||||
import com.mpatric.mp3agic.InvalidDataException
|
||||
import com.mpatric.mp3agic.Mp3File
|
||||
import com.shabinder.common.core_components.media_converter.MediaConverter
|
||||
import com.shabinder.common.core_components.parallel_executor.ParallelExecutor
|
||||
import com.shabinder.common.core_components.picture.Picture
|
||||
import com.shabinder.common.core_components.preference_manager.PreferenceManager
|
||||
import com.shabinder.common.core_components.removeAllTags
|
||||
import com.shabinder.common.core_components.setId3v1Tags
|
||||
import com.shabinder.common.core_components.setId3v2TagsAndSaveFile
|
||||
import com.shabinder.common.database.SpotiFlyerDatabase
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.models.dispatcherIO
|
||||
import com.shabinder.common.models.event.coroutines.SuspendableEvent
|
||||
@ -36,6 +38,7 @@ import com.shabinder.common.models.event.coroutines.map
|
||||
import com.shabinder.database.Database
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.skija.Image
|
||||
@ -50,10 +53,15 @@ import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import javax.imageio.ImageIO
|
||||
|
||||
actual internal fun fileManagerModule() = module {
|
||||
internal actual fun fileManagerModule() = module {
|
||||
single { DesktopFileManager(get(), get(), get(), get()) } bind FileManager::class
|
||||
}
|
||||
|
||||
val DownloadProgressFlow: MutableSharedFlow<HashMap<String, DownloadStatus>> = MutableSharedFlow(1)
|
||||
|
||||
// Scope Allowing 4 Parallel Downloads
|
||||
val DownloadScope = ParallelExecutor(Dispatchers.IO)
|
||||
|
||||
class DesktopFileManager(
|
||||
override val logger: Kermit,
|
||||
override val preferenceManager: PreferenceManager,
|
||||
|
@ -17,9 +17,7 @@
|
||||
package com.shabinder.common.core_components.file_manager
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.core_components.DownloadProgressFlow
|
||||
import com.shabinder.common.core_components.ID3Writer
|
||||
import com.shabinder.common.core_components.allTracksStatus
|
||||
import com.shabinder.common.core_components.media_converter.MediaConverter
|
||||
import com.shabinder.common.core_components.picture.Picture
|
||||
import com.shabinder.common.core_components.preference_manager.PreferenceManager
|
||||
@ -34,6 +32,7 @@ import com.shabinder.common.utils.removeIllegalChars
|
||||
import com.shabinder.database.Database
|
||||
import kotlinext.js.Object
|
||||
import kotlinext.js.js
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import org.khronos.webgl.ArrayBuffer
|
||||
import org.khronos.webgl.Int8Array
|
||||
@ -142,3 +141,9 @@ class WebFileManager(
|
||||
fun ByteArray.toArrayBuffer(): ArrayBuffer {
|
||||
return this.unsafeCast<Int8Array>().buffer
|
||||
}
|
||||
|
||||
val DownloadProgressFlow: MutableSharedFlow<HashMap<String, DownloadStatus>> = MutableSharedFlow(1)
|
||||
|
||||
// Error:https://github.com/Kotlin/kotlinx.atomicfu/issues/182
|
||||
// val DownloadScope = ParallelExecutor(Dispatchers.Default) //Download Pool of 4 parallel
|
||||
val allTracksStatus: HashMap<String, DownloadStatus> = hashMapOf()
|
||||
|
@ -16,22 +16,16 @@
|
||||
|
||||
package com.shabinder.common.providers
|
||||
|
||||
import com.shabinder.common.core_components.file_manager.DownloadProgressFlow
|
||||
import com.shabinder.common.core_components.file_manager.DownloadScope
|
||||
import com.shabinder.common.core_components.file_manager.FileManager
|
||||
import com.shabinder.common.core_components.file_manager.downloadFile
|
||||
import com.shabinder.common.core_components.parallel_executor.ParallelExecutor
|
||||
import com.shabinder.common.models.DownloadResult
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import com.shabinder.common.models.SpotiFlyerException
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
|
||||
val DownloadProgressFlow: MutableSharedFlow<HashMap<String, DownloadStatus>> = MutableSharedFlow(1)
|
||||
|
||||
// Scope Allowing 4 Parallel Downloads
|
||||
val DownloadScope = ParallelExecutor(Dispatchers.IO)
|
||||
|
||||
actual suspend fun downloadTracks(
|
||||
list: List<TrackDetails>,
|
||||
fetcher: FetchPlatformQueryResult,
|
||||
|
@ -16,19 +16,14 @@
|
||||
|
||||
package com.shabinder.common.providers
|
||||
|
||||
import com.shabinder.common.core_components.file_manager.DownloadProgressFlow
|
||||
import com.shabinder.common.core_components.file_manager.FileManager
|
||||
import com.shabinder.common.core_components.file_manager.allTracksStatus
|
||||
import com.shabinder.common.core_components.file_manager.downloadFile
|
||||
import com.shabinder.common.models.*
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
val DownloadProgressFlow: MutableSharedFlow<HashMap<String, DownloadStatus>> = MutableSharedFlow(1)
|
||||
|
||||
// Error:https://github.com/Kotlin/kotlinx.atomicfu/issues/182
|
||||
// val DownloadScope = ParallelExecutor(Dispatchers.Default) //Download Pool of 4 parallel
|
||||
val allTracksStatus: HashMap<String, DownloadStatus> = hashMapOf()
|
||||
|
||||
actual suspend fun downloadTracks(
|
||||
list: List<TrackDetails>,
|
||||
fetcher: FetchPlatformQueryResult,
|
||||
|
Loading…
Reference in New Issue
Block a user