mirror of
https://github.com/gedoor/legado.git
synced 2024-07-17 00:58:29 +08:00
优化
This commit is contained in:
parent
1f3bdf0587
commit
3751af35f4
@ -26,7 +26,7 @@ object ReplaceAnalyzer {
|
|||||||
return runCatching {
|
return runCatching {
|
||||||
val replaceRule: ReplaceRule? =
|
val replaceRule: ReplaceRule? =
|
||||||
GSON.fromJsonObject<ReplaceRule>(json.trim()).getOrNull()
|
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 jsonItem = jsonPath.parse(json.trim())
|
||||||
val rule = ReplaceRule()
|
val rule = ReplaceRule()
|
||||||
rule.id = jsonItem.readLong("$.id") ?: System.currentTimeMillis()
|
rule.id = jsonItem.readLong("$.id") ?: System.currentTimeMillis()
|
||||||
|
@ -589,7 +589,7 @@ object ChapterProvider {
|
|||||||
x = x1
|
x = x1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exceed(absStartX, textLine)
|
exceed(absStartX, textLine, words)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -618,7 +618,7 @@ object ChapterProvider {
|
|||||||
textLine.indentWidth = x
|
textLine.indentWidth = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exceed(absStartX, textLine)
|
exceed(absStartX, textLine, words)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStringArrayAndTextWidths(
|
fun getStringArrayAndTextWidths(
|
||||||
@ -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 visibleEnd = absStartX + visibleWidth
|
||||||
val columns = textLine.columns
|
val endX = textLine.columns.lastOrNull()?.end ?: return
|
||||||
val endX = columns.lastOrNull()?.end ?: return
|
|
||||||
if (endX > visibleEnd) {
|
if (endX > visibleEnd) {
|
||||||
val cc = (endX - visibleEnd) / columns.size
|
val cc = (endX - visibleEnd) / words.size
|
||||||
for (i in 0..columns.lastIndex) {
|
for (i in 0..words.lastIndex) {
|
||||||
textLine.getColumnReverseAt(i).let {
|
textLine.getColumnReverseAt(i).let {
|
||||||
val py = cc * (columns.size - i)
|
val py = cc * (words.size - i)
|
||||||
it.start = it.start - py
|
it.start = it.start - py
|
||||||
it.end = it.end - py
|
it.end = it.end - py
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user