1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-06-26 23:22:52 +00:00

Use workDataOf

This commit is contained in:
Isira Seneviratne 2025-03-08 09:18:30 +05:30
parent abaf16e12b
commit d805679a5e

View File

@ -14,6 +14,7 @@ import androidx.work.Data
import androidx.work.ForegroundInfo import androidx.work.ForegroundInfo
import androidx.work.WorkManager import androidx.work.WorkManager
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import androidx.work.workDataOf
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
@ -192,24 +193,12 @@ sealed class SubscriptionImportInput : Parcelable {
data class PreviousExportMode(val url: String) : SubscriptionImportInput() data class PreviousExportMode(val url: String) : SubscriptionImportInput()
fun toData(): Data { fun toData(): Data {
return when (this) { val (mode, serviceId, url) = when (this) {
is ChannelUrlMode -> Data.Builder() is ChannelUrlMode -> Triple(CHANNEL_URL_MODE, serviceId, url)
.putInt("mode", CHANNEL_URL_MODE) is InputStreamMode -> Triple(INPUT_STREAM_MODE, serviceId, url)
.putInt("service_id", serviceId) is PreviousExportMode -> Triple(PREVIOUS_EXPORT_MODE, null, url)
.putString("url", url)
.build()
is InputStreamMode ->
Data.Builder()
.putInt("mode", INPUT_STREAM_MODE)
.putInt("service_id", serviceId)
.putString("url", url)
.build()
is PreviousExportMode ->
Data.Builder()
.putInt("mode", PREVIOUS_EXPORT_MODE)
.putString("url", url)
.build()
} }
return workDataOf("mode" to mode, "service_id" to serviceId, "url" to url)
} }
companion object { companion object {