mirror of
https://github.com/gedoor/legado.git
synced 2024-07-04 23:36:56 +08:00
Compare commits
3 Commits
53608b508b
...
7cf7ec7889
Author | SHA1 | Date | |
---|---|---|---|
|
7cf7ec7889 | ||
|
0337e465de | ||
|
6aa0d9a239 |
|
@ -188,7 +188,6 @@ class ContentProcessor private constructor(
|
|||
mContent = mContent.replace('\u00A0', ' ')
|
||||
}
|
||||
val contents = arrayListOf<String>()
|
||||
val paragraphIndent = ReadBookConfig.paragraphIndent
|
||||
mContent.split("\n").forEach { str ->
|
||||
val paragraph = str.trim {
|
||||
it.code <= 0x20 || it == ' '
|
||||
|
@ -197,14 +196,10 @@ class ContentProcessor private constructor(
|
|||
if (contents.isEmpty() && includeTitle) {
|
||||
contents.add(paragraph)
|
||||
} else {
|
||||
contents.add("$paragraphIndent$paragraph")
|
||||
contents.add("${ReadBookConfig.paragraphIndent}$paragraph")
|
||||
}
|
||||
}
|
||||
}
|
||||
if (contents.isEmpty()) {
|
||||
contents.add("${paragraphIndent}加载正文失败")
|
||||
contents.add("${paragraphIndent}内容处理后为空")
|
||||
}
|
||||
return BookContent(sameTitleRemoved, contents, effectiveReplaceRules)
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||
}
|
||||
nowSpeak = textChapter.getParagraphNum(readAloudNumber + 1, readAloudByPage) - 1
|
||||
if (!readAloudByPage && startPos == 0 && !toLast) {
|
||||
pos = page.lines.first().chapterPosition -
|
||||
pos = page.chapterPosition -
|
||||
textChapter.paragraphs[nowSpeak].chapterPosition
|
||||
}
|
||||
if (toLast) {
|
||||
|
@ -226,7 +226,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||
readAloudNumber = textChapter.getLastParagraphPosition()
|
||||
nowSpeak = contentList.lastIndex
|
||||
if (page.paragraphs.size == 1) {
|
||||
pos = page.lines.first().chapterPosition -
|
||||
pos = page.chapterPosition -
|
||||
textChapter.paragraphs[nowSpeak].chapterPosition
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ data class TextChapter(
|
|||
*/
|
||||
fun getReadLength(pageIndex: Int): Int {
|
||||
if (pageIndex < 0) return 0
|
||||
return pages[min(pageIndex, lastIndex)].lines.first().chapterPosition
|
||||
return pages[min(pageIndex, lastIndex)].chapterPosition
|
||||
/*
|
||||
var length = 0
|
||||
val maxIndex = min(pageIndex, pages.size)
|
||||
|
@ -224,14 +224,13 @@ data class TextChapter(
|
|||
return -1
|
||||
}
|
||||
val bIndex = pages.fastBinarySearchBy(charIndex, 0, pageSize) {
|
||||
it.lines.first().chapterPosition
|
||||
it.chapterPosition
|
||||
}
|
||||
val index = abs(bIndex + 1) - 1
|
||||
// 判断是否已经排版到 charIndex ,没有则返回 -1
|
||||
if (!isCompleted && index == pageSize - 1) {
|
||||
val page = pages[index]
|
||||
val line = page.lines.first()
|
||||
val pageEndPos = line.chapterPosition + page.charSize
|
||||
val pageEndPos = page.chapterPosition + page.charSize
|
||||
if (charIndex > pageEndPos) {
|
||||
return -1
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ data class TextPage(
|
|||
val lines: List<TextLine> get() = textLines
|
||||
val lineSize: Int get() = textLines.size
|
||||
val charSize: Int get() = text.length.coerceAtLeast(1)
|
||||
val chapterPosition: Int get() = textLines.first().chapterPosition
|
||||
val searchResult = hashSetOf<TextColumn>()
|
||||
var isMsgPage: Boolean = false
|
||||
var canvasRecorder = CanvasRecorderFactory.create(true)
|
||||
|
|
|
@ -177,7 +177,7 @@ class TextChapterLayout(
|
|||
val contents = bookContent.textList
|
||||
var absStartX = paddingLeft
|
||||
var durY = 0f
|
||||
if (ReadBookConfig.titleMode != 2 || bookChapter.isVolume) {
|
||||
if (ReadBookConfig.titleMode != 2 || bookChapter.isVolume || contents.isEmpty()) {
|
||||
//标题非隐藏
|
||||
displayTitle.splitNotBlank("\n").forEach { text ->
|
||||
setTypeText(
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"eslint": "^8.40.0",
|
||||
"eslint": "^9.4.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"eslint-plugin-vue": "^9.12.0",
|
||||
|
|
Loading…
Reference in New Issue
Block a user