diff --git a/app/src/main/java/io/legado/app/constant/BookType.kt b/app/src/main/java/io/legado/app/constant/BookType.kt index 0e48ffc88..470f48999 100644 --- a/app/src/main/java/io/legado/app/constant/BookType.kt +++ b/app/src/main/java/io/legado/app/constant/BookType.kt @@ -1,8 +1,15 @@ package io.legado.app.constant +import androidx.annotation.IntDef + object BookType { const val default = 0 // 0 文本 const val audio = 1 // 1 音频 const val image = 3 //图片 const val local = "loc_book" + + @Target(AnnotationTarget.VALUE_PARAMETER) + @Retention(AnnotationRetention.SOURCE) + @IntDef(default, audio, image) + annotation class Type } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 7010adef2..a7684f89a 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -131,43 +131,45 @@ data class Book( return charset(charset ?: "UTF-8") } - private fun config(): ReadConfig { - if (readConfig == null) { - readConfig = ReadConfig() + @IgnoredOnParcel + val config: ReadConfig + get() { + if (readConfig == null) { + readConfig = ReadConfig() + } + return readConfig!! } - return readConfig!! - } fun setReverseToc(reverseToc: Boolean) { - config().reverseToc = reverseToc + config.reverseToc = reverseToc } fun getReverseToc(): Boolean { - return config().reverseToc + return config.reverseToc } fun setUseReplaceRule(useReplaceRule: Boolean) { - config().useReplaceRule = useReplaceRule + config.useReplaceRule = useReplaceRule } fun getUseReplaceRule(): Boolean { - return config().useReplaceRule ?: AppConfig.replaceEnableDefault + return config.useReplaceRule ?: AppConfig.replaceEnableDefault } fun setReSegment(reSegment: Boolean) { - config().reSegment = reSegment + config.reSegment = reSegment } fun getReSegment(): Boolean { - return config().reSegment + return config.reSegment } fun setPageAnim(pageAnim: Int?) { - config().pageAnim = pageAnim + config.pageAnim = pageAnim } fun getPageAnim(): Int { - var pageAnim = config().pageAnim ?: ReadBookConfig.pageAnim + var pageAnim = config.pageAnim ?: ReadBookConfig.pageAnim if (pageAnim < 0) { pageAnim = ReadBookConfig.pageAnim } @@ -175,31 +177,31 @@ data class Book( } fun setImageStyle(imageStyle: String?) { - config().imageStyle = imageStyle + config.imageStyle = imageStyle } fun getImageStyle(): String? { - return config().imageStyle + return config.imageStyle } fun setTtsEngine(ttsEngine: String?) { - config().ttsEngine = ttsEngine + config.ttsEngine = ttsEngine } fun getTtsEngine(): String? { - return config().ttsEngine + return config.ttsEngine } fun setSplitLongChapter(limitLongContent: Boolean) { - config().splitLongChapter = limitLongContent + config.splitLongChapter = limitLongContent } fun getSplitLongChapter(): Boolean { - return config().splitLongChapter + return config.splitLongChapter } fun getDelTag(tag: Long): Boolean { - return config().delTag and tag == tag + return config.delTag and tag == tag } fun getFolderName(): String {