cloudstream/app/src/main/java/com/lagradost/cloudstream3/services/VideoDownloadService.kt
2021-07-05 22:28:50 +02:00

23 lines
No EOL
899 B
Kotlin

package com.lagradost.cloudstream3.services
import android.app.IntentService
import android.content.Intent
import com.lagradost.cloudstream3.utils.VideoDownloadManager
class VideoDownloadService : IntentService("VideoDownloadService") {
override fun onHandleIntent(intent: Intent?) {
if (intent != null) {
val id = intent.getIntExtra("id", -1)
val type = intent.getStringExtra("type")
if (id != -1 && type != null) {
val state = when (type) {
"resume" -> VideoDownloadManager.DownloadActionType.Resume
"pause" -> VideoDownloadManager.DownloadActionType.Pause
"stop" -> VideoDownloadManager.DownloadActionType.Stop
else -> return
}
VideoDownloadManager.downloadEvent.invoke(Pair(id, state))
}
}
}
}