优化
This commit is contained in:
@@ -115,8 +115,6 @@ data class Book(
|
|||||||
|
|
||||||
fun getUnreadChapterNum() = max(totalChapterNum - durChapterIndex - 1, 0)
|
fun getUnreadChapterNum() = max(totalChapterNum - durChapterIndex - 1, 0)
|
||||||
|
|
||||||
fun getDisplayTag() = if (customTag.isNullOrBlank()) kind else customTag
|
|
||||||
|
|
||||||
fun getDisplayCover() = if (customCoverUrl.isNullOrEmpty()) coverUrl else customCoverUrl
|
fun getDisplayCover() = if (customCoverUrl.isNullOrEmpty()) coverUrl else customCoverUrl
|
||||||
|
|
||||||
fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro
|
fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro
|
||||||
@@ -178,11 +176,6 @@ data class Book(
|
|||||||
config().imageStyle = imageStyle
|
config().imageStyle = imageStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setDelTag(tag: Long) {
|
|
||||||
config().delTag =
|
|
||||||
if ((config().delTag and tag) == tag) config().delTag and tag.inv() else config().delTag or tag
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getDelTag(tag: Long): Boolean {
|
fun getDelTag(tag: Long): Boolean {
|
||||||
return config().delTag and tag == tag
|
return config().delTag and tag == tag
|
||||||
}
|
}
|
||||||
@@ -259,7 +252,6 @@ data class Book(
|
|||||||
companion object {
|
companion object {
|
||||||
const val hTag = 2L
|
const val hTag = 2L
|
||||||
const val rubyTag = 4L
|
const val rubyTag = 4L
|
||||||
const val imgTag = 8L
|
|
||||||
const val imgStyleDefault = "DEFAULT"
|
const val imgStyleDefault = "DEFAULT"
|
||||||
const val imgStyleFull = "FULL"
|
const val imgStyleFull = "FULL"
|
||||||
const val imgStyleText = "TEXT"
|
const val imgStyleText = "TEXT"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.legado.app.help.DefaultData
|
|||||||
import io.legado.app.utils.EncodingDetect
|
import io.legado.app.utils.EncodingDetect
|
||||||
import io.legado.app.utils.MD5Utils
|
import io.legado.app.utils.MD5Utils
|
||||||
import io.legado.app.utils.StringUtils
|
import io.legado.app.utils.StringUtils
|
||||||
|
import io.legado.app.utils.Utf8BomUtils
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
import java.util.regex.Matcher
|
import java.util.regex.Matcher
|
||||||
@@ -64,7 +65,12 @@ class TextFile(private val book: Book) {
|
|||||||
//读取的长度
|
//读取的长度
|
||||||
var length: Int
|
var length: Int
|
||||||
val buffer = ByteArray(bufferSize)
|
val buffer = ByteArray(bufferSize)
|
||||||
var bufferStart = 0
|
var bufferStart = 3
|
||||||
|
bis.read(buffer, 0, 3)
|
||||||
|
if (Utf8BomUtils.hasBom(buffer)) {
|
||||||
|
bufferStart = 0
|
||||||
|
curOffset = 3
|
||||||
|
}
|
||||||
//获取文件中的数据到buffer,直到没有数据为止
|
//获取文件中的数据到buffer,直到没有数据为止
|
||||||
while (bis.read(buffer, bufferStart, bufferSize - bufferStart)
|
while (bis.read(buffer, bufferStart, bufferSize - bufferStart)
|
||||||
.also { length = it } > 0
|
.also { length = it } > 0
|
||||||
@@ -159,6 +165,7 @@ class TextFile(private val book: Book) {
|
|||||||
return analyze(tocRules.firstOrNull()?.rule?.toPattern(Pattern.MULTILINE))
|
return analyze(tocRules.firstOrNull()?.rule?.toPattern(Pattern.MULTILINE))
|
||||||
}
|
}
|
||||||
} else { //进行本地虚拟分章
|
} else { //进行本地虚拟分章
|
||||||
|
bufferStart = 0
|
||||||
//章节在buffer的偏移量
|
//章节在buffer的偏移量
|
||||||
var chapterOffset = 0
|
var chapterOffset = 0
|
||||||
//当前剩余可分配的长度
|
//当前剩余可分配的长度
|
||||||
|
|||||||
Reference in New Issue
Block a user