Update ChapterProvider.kt

优化
pull/1123/head
bushixuanqi 3 years ago committed by GitHub
parent 7475473948
commit eec9558a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@ -111,26 +111,27 @@ object ChapterProvider {
) )
} }
} else if (book.getImageStyle() != Book.imgStyleText) { } else if (book.getImageStyle() != Book.imgStyleText) {
content.replace(AppPattern.imgPattern.toRegex(), "\n\$0\n") var contentX = content.replace(AppPattern.imgPattern.toRegex(), "\n\$0\n").split("\n")
.split("\n").forEach { text -> val start = contentX.first() == "\n"
if (text.isNotBlank()) { val end = contentX.last() == "\n"
if (!text.startsWith("<img src=\"")) { //非图片 if(start || end )contentX = contentX.subList(if(start) 1 else 0,if(end) contentX.size-1 else contentX.size )
val isTitle = index == 0 contentX.forEach { text ->
val textPaint = if (isTitle) titlePaint else contentPaint if (!text.startsWith("<img src=\"")) { //非图片
if (!(isTitle && ReadBookConfig.titleMode == 2)) { val isTitle = index == 0
durY = setTypeText( val textPaint = if (isTitle) titlePaint else contentPaint
text, durY, textPages, if (!(isTitle && ReadBookConfig.titleMode == 2)) {
stringBuilder, isTitle, textPaint durY = setTypeText(
) text, durY, textPages,
} stringBuilder, isTitle, textPaint
} else { //图片 )
durY = setTypeImage(
book, bookChapter, text.substring(10, text.length-2),
durY, textPages, book.getImageStyle()
)
}
} }
} else { //图片
durY = setTypeImage(
book, bookChapter, text.substring(10, text.length-2),
durY, textPages, book.getImageStyle()
)
} }
}
} }
} }
textPages.last().height = durY + 20.dp textPages.last().height = durY + 20.dp

Loading…
Cancel
Save