mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
e0a51033c1
commit
1f4c1d1bf4
@ -34,7 +34,7 @@ object LocalBook {
|
||||
UmdFile.getChapterList(book)
|
||||
}
|
||||
else -> {
|
||||
TextFile().analyze(book)
|
||||
TextFile.getChapterList(book)
|
||||
}
|
||||
}
|
||||
if (chapters.isEmpty()) {
|
||||
|
@ -14,13 +14,13 @@ import java.nio.charset.Charset
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class TextFile {
|
||||
class TextFile(private val book: Book) {
|
||||
|
||||
private val tocRules = arrayListOf<TxtTocRule>()
|
||||
private lateinit var charset: Charset
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun analyze(book: Book): ArrayList<BookChapter> {
|
||||
fun getChapterList(): ArrayList<BookChapter> {
|
||||
val bookFile = getBookFile(book)
|
||||
if (book.charset == null) {
|
||||
book.charset = EncodingDetect.getEncode(bookFile)
|
||||
@ -249,6 +249,10 @@ class TextFile {
|
||||
//没有标题的时候,每个章节的最大长度
|
||||
private const val MAX_LENGTH_WITH_NO_CHAPTER = 10 * 1024
|
||||
|
||||
fun getChapterList(book: Book): ArrayList<BookChapter> {
|
||||
return TextFile(book).getChapterList()
|
||||
}
|
||||
|
||||
fun getContent(book: Book, bookChapter: BookChapter): String {
|
||||
val bookFile = getBookFile(book)
|
||||
//获取文件流
|
||||
|
Loading…
Reference in New Issue
Block a user