|
|
@ -113,11 +113,20 @@ object ChapterProvider { |
|
|
|
var absStartX = paddingLeft |
|
|
|
var absStartX = paddingLeft |
|
|
|
var durY = 0f |
|
|
|
var durY = 0f |
|
|
|
textPages.add(TextPage()) |
|
|
|
textPages.add(TextPage()) |
|
|
|
contents.forEachIndexed { index, content -> |
|
|
|
if (ReadBookConfig.titleMode != 2) { |
|
|
|
val isTitle = index == 0 |
|
|
|
displayTitle.splitNotBlank("\n").forEach { text -> |
|
|
|
val isTitleWithNoContent = isTitle && contents.size == 1 |
|
|
|
setTypeText( |
|
|
|
val isVolumeTitle = isTitle && bookChapter.isVolume |
|
|
|
absStartX, durY, text, textPages, stringBuilder, titlePaint, |
|
|
|
val textPaint = if (isTitle) titlePaint else contentPaint |
|
|
|
isTitle = true, |
|
|
|
|
|
|
|
isTitleWithNoContent = contents.isEmpty(), |
|
|
|
|
|
|
|
isVolumeTitle = bookChapter.isVolume |
|
|
|
|
|
|
|
).let { |
|
|
|
|
|
|
|
absStartX = it.first |
|
|
|
|
|
|
|
durY = it.second |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
contents.forEach { content -> |
|
|
|
if (book.getImageStyle() == Book.imgStyleText) { |
|
|
|
if (book.getImageStyle() == Book.imgStyleText) { |
|
|
|
var text = content.replace(srcReplaceChar, "▣") |
|
|
|
var text = content.replace(srcReplaceChar, "▣") |
|
|
|
val srcList = LinkedList<String>() |
|
|
|
val srcList = LinkedList<String>() |
|
|
@ -132,29 +141,24 @@ object ChapterProvider { |
|
|
|
} |
|
|
|
} |
|
|
|
matcher.appendTail(sb) |
|
|
|
matcher.appendTail(sb) |
|
|
|
text = sb.toString() |
|
|
|
text = sb.toString() |
|
|
|
if (!(isTitle && ReadBookConfig.titleMode == 2)) { |
|
|
|
setTypeText( |
|
|
|
setTypeText( |
|
|
|
absStartX, durY, text, textPages, stringBuilder, contentPaint, |
|
|
|
absStartX, durY, text, textPages, stringBuilder, |
|
|
|
srcList = srcList |
|
|
|
isTitle, isTitleWithNoContent, isVolumeTitle, textPaint, srcList |
|
|
|
).let { |
|
|
|
).let { |
|
|
|
absStartX = it.first |
|
|
|
absStartX = it.first |
|
|
|
durY = it.second |
|
|
|
durY = it.second |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else if (book.getImageStyle() != Book.imgStyleText) { |
|
|
|
} else { |
|
|
|
val matcher = AppPattern.imgPattern.matcher(content) |
|
|
|
val matcher = AppPattern.imgPattern.matcher(content) |
|
|
|
var start = 0 |
|
|
|
var start = 0 |
|
|
|
while (matcher.find()) { |
|
|
|
while (matcher.find()) { |
|
|
|
val text = content.substring(start, matcher.start()) |
|
|
|
val text = content.substring(start, matcher.start()) |
|
|
|
if (text.isNotBlank()) { |
|
|
|
if (text.isNotBlank()) { |
|
|
|
if (!(isTitle && ReadBookConfig.titleMode == 2)) { |
|
|
|
setTypeText( |
|
|
|
setTypeText( |
|
|
|
absStartX, durY, text, textPages, stringBuilder, contentPaint |
|
|
|
absStartX, durY, text, textPages, stringBuilder, |
|
|
|
).let { |
|
|
|
isTitle, isTitleWithNoContent, isVolumeTitle, textPaint |
|
|
|
absStartX = it.first |
|
|
|
).let { |
|
|
|
durY = it.second |
|
|
|
absStartX = it.first |
|
|
|
|
|
|
|
durY = it.second |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
durY = setTypeImage( |
|
|
|
durY = setTypeImage( |
|
|
@ -166,14 +170,11 @@ object ChapterProvider { |
|
|
|
if (start < content.length) { |
|
|
|
if (start < content.length) { |
|
|
|
val text = content.substring(start, content.length) |
|
|
|
val text = content.substring(start, content.length) |
|
|
|
if (text.isNotBlank()) { |
|
|
|
if (text.isNotBlank()) { |
|
|
|
if (!(isTitle && ReadBookConfig.titleMode == 2)) { |
|
|
|
setTypeText( |
|
|
|
setTypeText( |
|
|
|
absStartX, durY, text, textPages, stringBuilder, contentPaint |
|
|
|
absStartX, durY, text, textPages, stringBuilder, |
|
|
|
).let { |
|
|
|
isTitle, isTitleWithNoContent, isVolumeTitle, textPaint |
|
|
|
absStartX = it.first |
|
|
|
).let { |
|
|
|
durY = it.second |
|
|
|
absStartX = it.first |
|
|
|
|
|
|
|
durY = it.second |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -271,10 +272,10 @@ object ChapterProvider { |
|
|
|
text: String, |
|
|
|
text: String, |
|
|
|
textPages: ArrayList<TextPage>, |
|
|
|
textPages: ArrayList<TextPage>, |
|
|
|
stringBuilder: StringBuilder, |
|
|
|
stringBuilder: StringBuilder, |
|
|
|
isTitle: Boolean, |
|
|
|
|
|
|
|
isTitleWithNoContent: Boolean, |
|
|
|
|
|
|
|
isVolumeTitle: Boolean, |
|
|
|
|
|
|
|
textPaint: TextPaint, |
|
|
|
textPaint: TextPaint, |
|
|
|
|
|
|
|
isTitle: Boolean = false, |
|
|
|
|
|
|
|
isTitleWithNoContent: Boolean = false, |
|
|
|
|
|
|
|
isVolumeTitle: Boolean = false, |
|
|
|
srcList: LinkedList<String>? = null |
|
|
|
srcList: LinkedList<String>? = null |
|
|
|
): Pair<Int, Float> { |
|
|
|
): Pair<Int, Float> { |
|
|
|
var absStartX = x |
|
|
|
var absStartX = x |
|
|
@ -332,9 +333,10 @@ object ChapterProvider { |
|
|
|
textLine.text = "$words\n" |
|
|
|
textLine.text = "$words\n" |
|
|
|
isLastLine = true |
|
|
|
isLastLine = true |
|
|
|
//标题x轴居中 |
|
|
|
//标题x轴居中 |
|
|
|
val startX = if (isTitle && ReadBookConfig.titleMode == 1 || isTitleWithNoContent || isVolumeTitle) |
|
|
|
val startX = |
|
|
|
(visibleWidth - layout.getLineWidth(lineIndex)) / 2 |
|
|
|
if (isTitle && ReadBookConfig.titleMode == 1 || isTitleWithNoContent || isVolumeTitle) |
|
|
|
else 0f |
|
|
|
(visibleWidth - layout.getLineWidth(lineIndex)) / 2 |
|
|
|
|
|
|
|
else 0f |
|
|
|
addCharsToLineLast( |
|
|
|
addCharsToLineLast( |
|
|
|
absStartX, |
|
|
|
absStartX, |
|
|
|
textLine, |
|
|
|
textLine, |
|
|
@ -603,8 +605,8 @@ object ChapterProvider { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun upLayout() { |
|
|
|
fun upLayout() { |
|
|
|
doublePage = (viewWidth > viewHeight || appCtx.isPad) |
|
|
|
doublePage = (viewWidth > viewHeight || appCtx.isPad) |
|
|
|
&& ReadBook.pageAnim() != 3 |
|
|
|
&& ReadBook.pageAnim() != 3 |
|
|
|
&& AppConfig.doublePageHorizontal |
|
|
|
&& AppConfig.doublePageHorizontal |
|
|
|
if (viewWidth > 0 && viewHeight > 0) { |
|
|
|
if (viewWidth > 0 && viewHeight > 0) { |
|
|
|
paddingLeft = ReadBookConfig.paddingLeft.dp |
|
|
|
paddingLeft = ReadBookConfig.paddingLeft.dp |
|
|
|
paddingTop = ReadBookConfig.paddingTop.dp |
|
|
|
paddingTop = ReadBookConfig.paddingTop.dp |
|
|
|