Book.kt: Modify functions into assigning style

Signed-off-by: 1552980358 <1552980358@qq.com>
pull/369/head
1552980358 5 years ago
parent d230d79bc7
commit 2bfbdef1eb
  1. 40
      app/src/main/java/io/legado/app/data/entities/Book.kt

@ -55,7 +55,7 @@ data class Book(
var originOrder: Int = 0, //书源排序 var originOrder: Int = 0, //书源排序
var useReplaceRule: Boolean = AppConfig.replaceEnableDefault, // 正文使用净化替换规则 var useReplaceRule: Boolean = AppConfig.replaceEnableDefault, // 正文使用净化替换规则
var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息) var variable: String? = null // 自定义书籍变量信息(用于书源规则检索书籍信息)
) : Parcelable, BaseBook { ): Parcelable, BaseBook {
fun isLocalBook(): Boolean { fun isLocalBook(): Boolean {
return origin == BookType.local return origin == BookType.local
@ -120,26 +120,24 @@ data class Book(
return name.replace(AppPattern.fileNameRegex, "") + MD5Utils.md5Encode16(bookUrl) return name.replace(AppPattern.fileNameRegex, "") + MD5Utils.md5Encode16(bookUrl)
} }
fun toSearchBook(): SearchBook { fun toSearchBook() = SearchBook(
return SearchBook( name = name,
name = name, author = author,
author = author, kind = kind,
kind = kind, bookUrl = bookUrl,
bookUrl = bookUrl, origin = origin,
origin = origin, originName = originName,
originName = originName, type = type,
type = type, wordCount = wordCount,
wordCount = wordCount, latestChapterTitle = latestChapterTitle,
latestChapterTitle = latestChapterTitle, coverUrl = coverUrl,
coverUrl = coverUrl, intro = intro,
intro = intro, tocUrl = tocUrl,
tocUrl = tocUrl, originOrder = originOrder,
originOrder = originOrder, variable = variable
variable = variable ).apply {
).apply { this.infoHtml = this@Book.infoHtml
this.infoHtml = this@Book.infoHtml this.tocHtml = this@Book.tocHtml
this.tocHtml = this@Book.tocHtml
}
} }
fun changeTo(newBook: Book) { fun changeTo(newBook: Book) {

Loading…
Cancel
Save