From a45270c54a76d620616948f32187c00153fa0e8d Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Fri, 7 Oct 2022 11:41:09 +0200 Subject: [PATCH] Make Info name nullable --- app/src/main/kotlin/it/vfsfitvnm/vimusic/models/Info.kt | 2 +- .../main/kotlin/it/vfsfitvnm/vimusic/savers/InfoSaver.kt | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/models/Info.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/models/Info.kt index 52ae2a6..161a3ca 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/models/Info.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/models/Info.kt @@ -2,5 +2,5 @@ package it.vfsfitvnm.vimusic.models data class Info( val id: String, - val name: String + val name: String? ) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/savers/InfoSaver.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/savers/InfoSaver.kt index d8422ea..12bd22d 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/savers/InfoSaver.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/savers/InfoSaver.kt @@ -4,12 +4,10 @@ import androidx.compose.runtime.saveable.Saver import androidx.compose.runtime.saveable.SaverScope import it.vfsfitvnm.vimusic.models.Info -object InfoSaver : Saver> { - override fun SaverScope.save(value: Info): List = listOf(value.id, value.name) +object InfoSaver : Saver> { + override fun SaverScope.save(value: Info) = listOf(value.id, value.name) - override fun restore(value: List): Info? { - return if (value.size == 2) Info(id = value[0], name = value[1]) else null - } + override fun restore(value: List) = Info(id = value[0] as String, name = value[1]) } val InfoListSaver = listSaver(InfoSaver)