-
Notifications
You must be signed in to change notification settings - Fork 136
/
HKeyframeEntity.kt
104 lines (93 loc) · 2.26 KB
/
HKeyframeEntity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@file:Suppress("PLUGIN_IS_NOT_ENABLED")
package com.yenaly.han1meviewer.logic.entity
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import androidx.room.TypeConverter
import androidx.room.TypeConverters
import com.yenaly.han1meviewer.logic.model.MultiItemEntity
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
/**
* @project Han1meViewer
* @author Yenaly Liew
*/
interface HKeyframeType : MultiItemEntity {
companion object {
const val H_KEYFRAME = 0
const val HEADER = 1
}
}
/**
* @project Han1meViewer
* @author Yenaly Liew
* @time 2023/11/12 012 12:14
*/
@Serializable
@Entity
@TypeConverters(HKeyframeEntity.KeyframeTypeConverter::class)
data class HKeyframeEntity(
@PrimaryKey val videoCode: String,
val title: String,
/**
* 关键帧列表
*/
val keyframes: MutableList<Keyframe>,
/**
* 最后修改时间
*/
val lastModifiedTime: Long = -1,
/**
* 创建时间
*/
val createdTime: Long = -1,
/**
* 作者,null 代表本地(自己创建的),非 null 代表共享
*/
val author: String? = null,
) : HKeyframeType {
/**
* 分组,一个系列为一组
*/
@Ignore
val group: String? = null
/**
* 所在集数
*/
@Ignore
val episode: Int = -1
@Ignore
override val itemType: Int = HKeyframeType.H_KEYFRAME
@Serializable
data class Keyframe(
/**
* 该关键帧的时间戳
*/
val position: Long,
/**
* 该关键帧的提示
*/
val prompt: String?,
)
class KeyframeTypeConverter {
@TypeConverter
fun fromKeyframeList(keyframes: MutableList<Keyframe>): String =
Json.encodeToString(keyframes)
@TypeConverter
fun toKeyframeList(keyframes: String): MutableList<Keyframe> =
Json.decodeFromString(keyframes)
}
}
/**
* @project Han1meViewer
* @author Yenaly Liew
*/
data class HKeyframeHeader(
val title: String,
/**
* 附属的关键帧列表
*/
val attached: List<HKeyframeEntity>,
override val itemType: Int = HKeyframeType.HEADER,
) : HKeyframeType