pull/1705/head
kunfei 3 years ago
parent 71a37a4057
commit 12acfca459
  1. 7
      app/src/main/java/io/legado/app/data/entities/BaseBook.kt
  2. 7
      app/src/main/java/io/legado/app/data/entities/Book.kt
  3. 7
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  4. 14
      app/src/main/java/io/legado/app/model/analyzeRule/RuleDataInterface.kt

@ -1,6 +1,7 @@
package io.legado.app.data.entities
import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON
import io.legado.app.utils.splitNotBlank
interface BaseBook : RuleDataInterface {
@ -9,10 +10,16 @@ interface BaseBook : RuleDataInterface {
var bookUrl: String
var kind: String?
var wordCount: String?
var variable: String?
var infoHtml: String?
var tocHtml: String?
override fun putVariable(key: String, value: String?) {
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}
fun getKindList(): List<String> {
val kindList = arrayListOf<String>()
wordCount?.let {

@ -99,7 +99,7 @@ data class Book(
@ColumnInfo(defaultValue = "0")
var originOrder: Int = 0,
// 自定义书籍变量信息(用于书源规则检索书籍信息)
var variable: String? = null,
override var variable: String? = null,
var readConfig: ReadConfig? = null
) : Parcelable, BaseBook {
@ -142,11 +142,6 @@ data class Book(
GSON.fromJsonObject<HashMap<String, String>>(variable).getOrNull() ?: hashMapOf()
}
override fun putVariable(key: String, value: String?) {
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}
@Ignore
@IgnoredOnParcel
override var infoHtml: String? = null

@ -36,7 +36,7 @@ data class SearchBook(
var latestChapterTitle: String? = null,
var tocUrl: String = "", // 目录页Url (toc=table of Contents)
var time: Long = System.currentTimeMillis(),
var variable: String? = null,
override var variable: String? = null,
var originOrder: Int = 0
) : Parcelable, BaseBook, Comparable<SearchBook> {
@ -63,11 +63,6 @@ data class SearchBook(
GSON.fromJsonObject<HashMap<String, String>>(variable).getOrNull() ?: HashMap()
}
override fun putVariable(key: String, value: String?) {
super.putVariable(key, value)
variable = GSON.toJson(variableMap)
}
@delegate:Transient
@delegate:Ignore
@IgnoredOnParcel

@ -5,10 +5,16 @@ interface RuleDataInterface {
val variableMap: HashMap<String, String>
fun putVariable(key: String, value: String?) {
if (value == null) {
variableMap.remove(key)
} else if (value.length < 1000) {
variableMap[key] = value
when {
value == null -> {
variableMap.remove(key)
}
value.length < 1000 -> {
variableMap[key] = value
}
else -> {
}
}
}

Loading…
Cancel
Save