mirror of
https://github.com/InvertGeek/MixFile.git
synced 2026-06-02 01:22:41 +08:00
fix data saving
This commit is contained in:
@@ -6,6 +6,7 @@ plugins {
|
||||
alias(libs.plugins.compose.compiler)
|
||||
id("com.google.gms.google-services")
|
||||
id("kotlin-parcelize")
|
||||
kotlin("plugin.serialization") version "2.2.0"
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -11,10 +11,12 @@ import com.donut.mixfile.activity.video.player.VideoPlayerScreen
|
||||
import com.donut.mixfile.ui.theme.MainTheme
|
||||
import com.donut.mixfile.util.cachedMutableOf
|
||||
import com.donut.mixfile.util.objects.MixActivity
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
var playHistory by cachedMutableOf(listOf<VideoHistory>(), "video_player_history_v2")
|
||||
|
||||
@Serializable
|
||||
data class VideoHistory(val time: Long, val hash: String, val episode: Int)
|
||||
|
||||
class VideoActivity : MixActivity("video") {
|
||||
|
||||
@@ -53,11 +53,13 @@ inline fun <reified T, reified C : Iterable<T>> cachedMutableOf(value: C, key: S
|
||||
constructCachedMutableValue(
|
||||
value,
|
||||
{
|
||||
kv.encode(key, it.toJsonString())
|
||||
errorDialog("保存数据失败 key=${key}") {
|
||||
kv.encode(key, it.toJsonString())
|
||||
}
|
||||
},
|
||||
getter@{
|
||||
var result = value
|
||||
catchError {
|
||||
errorDialog("读取数据失败 key=${key}") {
|
||||
if (kv.containsKey(key)) {
|
||||
val json: C = kv.decodeString(key)?.parseJsonObject() ?: value
|
||||
result = json
|
||||
|
||||
Reference in New Issue
Block a user