Use immutable collections in more places

This commit is contained in:
arkon
2023-11-11 22:43:50 -05:00
parent dd998be1e7
commit 336221a972
35 changed files with 252 additions and 152 deletions

View File

@ -80,7 +80,7 @@ class EpubFile(file: File) : Closeable {
/**
* Returns all the pages from the epub.
*/
fun getPagesFromDocument(document: Document): List<String> {
private fun getPagesFromDocument(document: Document): List<String> {
val pages = document.select("manifest > item")
.filter { node -> "application/xhtml+xml" == node.attr("media-type") }
.associateBy { it.attr("id") }
@ -102,10 +102,9 @@ class EpubFile(file: File) : Closeable {
val imageBasePath = getParentDirectory(entryPath)
document.allElements.forEach {
if (it.tagName() == "img") {
result.add(resolveZipPath(imageBasePath, it.attr("src")))
} else if (it.tagName() == "image") {
result.add(resolveZipPath(imageBasePath, it.attr("xlink:href")))
when (it.tagName()) {
"img" -> result.add(resolveZipPath(imageBasePath, it.attr("src")))
"image" -> result.add(resolveZipPath(imageBasePath, it.attr("xlink:href")))
}
}
}