Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Oct 16, 2023
1 parent 1f3bdf0 commit 3751af3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/io/legado/app/help/ReplaceAnalyzer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ReplaceAnalyzer {
return runCatching {
val replaceRule: ReplaceRule? =
GSON.fromJsonObject<ReplaceRule>(json.trim()).getOrNull()
if (replaceRule == null || replaceRule.pattern.isBlank()) {
if (replaceRule == null || replaceRule.pattern.isEmpty()) {
val jsonItem = jsonPath.parse(json.trim())
val rule = ReplaceRule()
rule.id = jsonItem.readLong("$.id") ?: System.currentTimeMillis()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ object ChapterProvider {
x = x1
}
}
exceed(absStartX, textLine)
exceed(absStartX, textLine, words)
}

/**
Expand Down Expand Up @@ -618,7 +618,7 @@ object ChapterProvider {
textLine.indentWidth = x
}
}
exceed(absStartX, textLine)
exceed(absStartX, textLine, words)
}

fun getStringArrayAndTextWidths(
Expand Down Expand Up @@ -690,15 +690,14 @@ object ChapterProvider {
/**
* 超出边界处理
*/
private fun exceed(absStartX: Int, textLine: TextLine) {
private fun exceed(absStartX: Int, textLine: TextLine, words: List<String>) {
val visibleEnd = absStartX + visibleWidth
val columns = textLine.columns
val endX = columns.lastOrNull()?.end ?: return
val endX = textLine.columns.lastOrNull()?.end ?: return
if (endX > visibleEnd) {
val cc = (endX - visibleEnd) / columns.size
for (i in 0..columns.lastIndex) {
val cc = (endX - visibleEnd) / words.size
for (i in 0..words.lastIndex) {
textLine.getColumnReverseAt(i).let {
val py = cc * (columns.size - i)
val py = cc * (words.size - i)
it.start = it.start - py
it.end = it.end - py
}
Expand Down

0 comments on commit 3751af3

Please sign in to comment.