|
|
@ -3,7 +3,11 @@ package io.legado.app.data.entities |
|
|
|
import android.os.Parcelable |
|
|
|
import android.os.Parcelable |
|
|
|
import androidx.room.Entity |
|
|
|
import androidx.room.Entity |
|
|
|
import androidx.room.ForeignKey |
|
|
|
import androidx.room.ForeignKey |
|
|
|
|
|
|
|
import androidx.room.Ignore |
|
|
|
import androidx.room.Index |
|
|
|
import androidx.room.Index |
|
|
|
|
|
|
|
import io.legado.app.utils.GSON |
|
|
|
|
|
|
|
import io.legado.app.utils.fromJsonObject |
|
|
|
|
|
|
|
import kotlinx.android.parcel.IgnoredOnParcel |
|
|
|
import kotlinx.android.parcel.Parcelize |
|
|
|
import kotlinx.android.parcel.Parcelize |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -11,7 +15,10 @@ import kotlinx.android.parcel.Parcelize |
|
|
|
@Entity( |
|
|
|
@Entity( |
|
|
|
tableName = "chapters", |
|
|
|
tableName = "chapters", |
|
|
|
primaryKeys = ["url", "bookUrl"], |
|
|
|
primaryKeys = ["url", "bookUrl"], |
|
|
|
indices = [(Index(value = ["bookUrl"], unique = false)), (Index(value = ["bookUrl", "index"], unique = true))], |
|
|
|
indices = [(Index(value = ["bookUrl"], unique = false)), (Index( |
|
|
|
|
|
|
|
value = ["bookUrl", "index"], |
|
|
|
|
|
|
|
unique = true |
|
|
|
|
|
|
|
))], |
|
|
|
foreignKeys = [(ForeignKey( |
|
|
|
foreignKeys = [(ForeignKey( |
|
|
|
entity = Book::class, |
|
|
|
entity = Book::class, |
|
|
|
parentColumns = ["bookUrl"], |
|
|
|
parentColumns = ["bookUrl"], |
|
|
@ -27,6 +34,25 @@ data class BookChapter( |
|
|
|
var resourceUrl: String? = null, // 音频真实URL |
|
|
|
var resourceUrl: String? = null, // 音频真实URL |
|
|
|
var tag: String? = null, // |
|
|
|
var tag: String? = null, // |
|
|
|
var start: Long? = null, // 章节起始位置 |
|
|
|
var start: Long? = null, // 章节起始位置 |
|
|
|
var end: Long? = null // 章节终止位置 |
|
|
|
var end: Long? = null, // 章节终止位置 |
|
|
|
) : Parcelable |
|
|
|
var variable: String? = null |
|
|
|
|
|
|
|
) : Parcelable { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
|
|
|
var variableMap: HashMap<String, String>? = null |
|
|
|
|
|
|
|
private set |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
if (field == null) { |
|
|
|
|
|
|
|
field = GSON.fromJsonObject<HashMap<String, String>>(variable) ?: HashMap() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return field |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun putVariable(key: String, value: String) { |
|
|
|
|
|
|
|
variableMap?.put(key, value) |
|
|
|
|
|
|
|
variable = GSON.toJson(variableMap) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|