pull/1630/head
kunfei 3 years ago
parent a40a7c47ed
commit c2d1c50dab
  1. 7
      app/src/main/java/io/legado/app/constant/BookType.kt
  2. 42
      app/src/main/java/io/legado/app/data/entities/Book.kt

@ -1,8 +1,15 @@
package io.legado.app.constant package io.legado.app.constant
import androidx.annotation.IntDef
object BookType { object BookType {
const val default = 0 // 0 文本 const val default = 0 // 0 文本
const val audio = 1 // 1 音频 const val audio = 1 // 1 音频
const val image = 3 //图片 const val image = 3 //图片
const val local = "loc_book" const val local = "loc_book"
@Target(AnnotationTarget.VALUE_PARAMETER)
@Retention(AnnotationRetention.SOURCE)
@IntDef(default, audio, image)
annotation class Type
} }

@ -131,43 +131,45 @@ data class Book(
return charset(charset ?: "UTF-8") return charset(charset ?: "UTF-8")
} }
private fun config(): ReadConfig { @IgnoredOnParcel
if (readConfig == null) { val config: ReadConfig
readConfig = ReadConfig() get() {
if (readConfig == null) {
readConfig = ReadConfig()
}
return readConfig!!
} }
return readConfig!!
}
fun setReverseToc(reverseToc: Boolean) { fun setReverseToc(reverseToc: Boolean) {
config().reverseToc = reverseToc config.reverseToc = reverseToc
} }
fun getReverseToc(): Boolean { fun getReverseToc(): Boolean {
return config().reverseToc return config.reverseToc
} }
fun setUseReplaceRule(useReplaceRule: Boolean) { fun setUseReplaceRule(useReplaceRule: Boolean) {
config().useReplaceRule = useReplaceRule config.useReplaceRule = useReplaceRule
} }
fun getUseReplaceRule(): Boolean { fun getUseReplaceRule(): Boolean {
return config().useReplaceRule ?: AppConfig.replaceEnableDefault return config.useReplaceRule ?: AppConfig.replaceEnableDefault
} }
fun setReSegment(reSegment: Boolean) { fun setReSegment(reSegment: Boolean) {
config().reSegment = reSegment config.reSegment = reSegment
} }
fun getReSegment(): Boolean { fun getReSegment(): Boolean {
return config().reSegment return config.reSegment
} }
fun setPageAnim(pageAnim: Int?) { fun setPageAnim(pageAnim: Int?) {
config().pageAnim = pageAnim config.pageAnim = pageAnim
} }
fun getPageAnim(): Int { fun getPageAnim(): Int {
var pageAnim = config().pageAnim ?: ReadBookConfig.pageAnim var pageAnim = config.pageAnim ?: ReadBookConfig.pageAnim
if (pageAnim < 0) { if (pageAnim < 0) {
pageAnim = ReadBookConfig.pageAnim pageAnim = ReadBookConfig.pageAnim
} }
@ -175,31 +177,31 @@ data class Book(
} }
fun setImageStyle(imageStyle: String?) { fun setImageStyle(imageStyle: String?) {
config().imageStyle = imageStyle config.imageStyle = imageStyle
} }
fun getImageStyle(): String? { fun getImageStyle(): String? {
return config().imageStyle return config.imageStyle
} }
fun setTtsEngine(ttsEngine: String?) { fun setTtsEngine(ttsEngine: String?) {
config().ttsEngine = ttsEngine config.ttsEngine = ttsEngine
} }
fun getTtsEngine(): String? { fun getTtsEngine(): String? {
return config().ttsEngine return config.ttsEngine
} }
fun setSplitLongChapter(limitLongContent: Boolean) { fun setSplitLongChapter(limitLongContent: Boolean) {
config().splitLongChapter = limitLongContent config.splitLongChapter = limitLongContent
} }
fun getSplitLongChapter(): Boolean { fun getSplitLongChapter(): Boolean {
return config().splitLongChapter return config.splitLongChapter
} }
fun getDelTag(tag: Long): Boolean { fun getDelTag(tag: Long): Boolean {
return config().delTag and tag == tag return config.delTag and tag == tag
} }
fun getFolderName(): String { fun getFolderName(): String {

Loading…
Cancel
Save