diff --git a/app/src/main/assets/help/ruleHelp.md b/app/src/main/assets/help/ruleHelp.md index 4845e43de..29518c406 100644 --- a/app/src/main/assets/help/ruleHelp.md +++ b/app/src/main/assets/help/ruleHelp.md @@ -1,7 +1,7 @@ # 源规则帮助 -* [书源帮助文档](https://alanskycn.gitee.io/teachme/Rule/source.html) -* [订阅源帮助文档](https://alanskycn.gitee.io/teachme/Rule/rss.html) +* [书源帮助文档](https://celetor.github.io/teachme/Rule/source.html) +* [订阅源帮助文档](https://celetor.github.io/teachme/Rule/rss.html) * 辅助键盘❓中可插入URL参数模板,打开帮助,js教程,正则教程,选择文件 * 规则标志, {{......}}内使用规则必须有明显的规则标志,没有规则标志当作js执行 ``` diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index 10f6de8f7..1873abc2f 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -288,21 +288,26 @@ object ReadBook : CoroutineScope by MainScope() { } fun setPageIndex(index: Int) { - val textChapter = curTextChapter - if (textChapter != null) { - val pageIndex = durPageIndex - if (index > pageIndex) { - textChapter.getPage(index - 2)?.recycleRecorders() - } - if (index < pageIndex) { - textChapter.getPage(index + 3)?.recycleRecorders() - } - } + recycleRecorders(durPageIndex, index) durChapterPos = curTextChapter?.getReadLength(index) ?: index saveRead(true) curPageChanged(true) } + fun recycleRecorders(beforeIndex: Int, afterIndex: Int) { + executor.execute { + val textChapter = curTextChapter + if (textChapter != null) { + if (afterIndex > beforeIndex) { + textChapter.getPage(afterIndex - 2)?.recycleRecorders() + } + if (afterIndex < beforeIndex) { + textChapter.getPage(afterIndex + 3)?.recycleRecorders() + } + } + } + } + fun openChapter(index: Int, durChapterPos: Int = 0, success: (() -> Unit)? = null) { if (index < chapterSize) { clearTextChapter() diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index 963639e73..53724ae85 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -79,8 +79,8 @@ data class TextLine( } } - fun getColumnReverseAt(index: Int): BaseColumn { - return textColumns[textColumns.lastIndex - index] + fun getColumnReverseAt(index: Int, offset: Int = 0): BaseColumn { + return textColumns[textColumns.lastIndex - offset - index] } fun getColumnsCount(): Int { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt index 4d097077e..24e5d9cdf 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt @@ -622,7 +622,7 @@ class TextChapterLayout( val spaceSize = words.count { it == " " } textLine.startX = absStartX + startX if (spaceSize > 1) { - val d = residualWidth / (spaceSize - 1) + val d = residualWidth / spaceSize textLine.wordSpacing = d var x = startX for (index in words.indices) { @@ -735,14 +735,25 @@ class TextChapterLayout( * 超出边界处理 */ private fun exceed(absStartX: Int, textLine: TextLine, words: List) { + var size = words.size + if (size < 2) return val visibleEnd = absStartX + visibleWidth - val endX = textLine.columns.lastOrNull()?.end?.roundToInt() ?: return + val columns = textLine.columns + var offset = 0 + val endColumn = if (words.last() == " ") { + size-- + offset++ + columns[columns.lastIndex - 1] + } else { + columns.last() + } + val endX = endColumn.end.roundToInt() if (endX > visibleEnd) { textLine.exceed = true - val cc = (endX - visibleEnd) / words.size - for (i in 0..words.lastIndex) { - textLine.getColumnReverseAt(i).let { - val py = cc * (words.size - i) + val cc = (endX - visibleEnd) / size + for (i in 0..