feat: 优化

pull/226/head
gedoor 5 years ago
parent 50c5385889
commit 4d1cbda379
  1. 2
      app/src/main/java/io/legado/app/data/entities/BaseBook.kt
  2. 22
      app/src/main/java/io/legado/app/data/entities/Book.kt
  3. 14
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt

@ -4,7 +4,7 @@ import io.legado.app.utils.splitNotBlank
interface BaseBook {
var bookUrl: String
var variableMap: HashMap<String, String>?
val variableMap: HashMap<String, String>
var kind: String?
var wordCount: String?

@ -71,15 +71,16 @@ data class Book(
return bookUrl.hashCode()
}
@Ignore
@delegate:Ignore
@IgnoredOnParcel
override var variableMap: HashMap<String, String>? = null
get() {
if (field == null) {
field = GSON.fromJsonObject<HashMap<String, String>>(variable) ?: HashMap()
}
return field
}
override val variableMap by lazy {
GSON.fromJsonObject<HashMap<String, String>>(variable) ?: HashMap()
}
override fun putVariable(key: String, value: String) {
variableMap[key] = value
variable = GSON.toJson(variableMap)
}
@Ignore
@IgnoredOnParcel
@ -97,11 +98,6 @@ data class Book(
fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro
override fun putVariable(key: String, value: String) {
variableMap?.put(key, value)
variable = GSON.toJson(variableMap)
}
fun fileCharset(): Charset {
return charset(charset ?: "UTF-8")
}

@ -63,18 +63,14 @@ data class SearchBook(
return other.originOrder - this.originOrder
}
@Ignore
@delegate:Ignore
@IgnoredOnParcel
override var variableMap: HashMap<String, String>? = null
get() {
if (field == null) {
field = GSON.fromJsonObject<HashMap<String, String>>(variable) ?: HashMap()
}
return field
}
override val variableMap by lazy {
GSON.fromJsonObject<HashMap<String, String>>(variable) ?: HashMap()
}
override fun putVariable(key: String, value: String) {
variableMap?.put(key, value)
variableMap[key] = value
variable = GSON.toJson(variableMap)
}

Loading…
Cancel
Save