|
|
@ -12,10 +12,7 @@ data class TextChapter( |
|
|
|
val chaptersSize: Int |
|
|
|
val chaptersSize: Int |
|
|
|
) { |
|
|
|
) { |
|
|
|
fun page(index: Int): TextPage? { |
|
|
|
fun page(index: Int): TextPage? { |
|
|
|
if (index >= 0 && index < pages.size) { |
|
|
|
return pages.getOrNull(index) |
|
|
|
return pages[index] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun lastPage(): TextPage? { |
|
|
|
fun lastPage(): TextPage? { |
|
|
@ -25,20 +22,6 @@ data class TextChapter( |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun scrollPage(): TextPage? { |
|
|
|
|
|
|
|
if (pages.isNotEmpty()) { |
|
|
|
|
|
|
|
val stringBuilder = StringBuilder() |
|
|
|
|
|
|
|
pages.forEach { |
|
|
|
|
|
|
|
stringBuilder.append(it.text) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return TextPage( |
|
|
|
|
|
|
|
index = 0, text = stringBuilder.toString(), title = title, |
|
|
|
|
|
|
|
pageSize = pages.size, chapterSize = chaptersSize, chapterIndex = position |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun lastIndex(): Int { |
|
|
|
fun lastIndex(): Int { |
|
|
|
return pages.size - 1 |
|
|
|
return pages.size - 1 |
|
|
|
} |
|
|
|
} |
|
|
@ -70,28 +53,6 @@ data class TextChapter( |
|
|
|
return stringBuilder.toString() |
|
|
|
return stringBuilder.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun getStartLine(pageIndex: Int): Int { |
|
|
|
|
|
|
|
if (pageLines.size > pageIndex) { |
|
|
|
|
|
|
|
var lines = 0 |
|
|
|
|
|
|
|
for (index: Int in 0 until pageIndex) { |
|
|
|
|
|
|
|
lines += pageLines[index] + 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return lines |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getPageIndex(line: Int): Int { |
|
|
|
|
|
|
|
var lines = 0 |
|
|
|
|
|
|
|
for (pageIndex in pageLines.indices) { |
|
|
|
|
|
|
|
lines += pageLines[pageIndex] + 1 |
|
|
|
|
|
|
|
if (line < lines) { |
|
|
|
|
|
|
|
return pageIndex |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getContent(): String { |
|
|
|
fun getContent(): String { |
|
|
|
val stringBuilder = StringBuilder() |
|
|
|
val stringBuilder = StringBuilder() |
|
|
|
pages.forEach { |
|
|
|
pages.forEach { |
|
|
|