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

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

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

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

Loading…
Cancel
Save