mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
d5a581f75b
commit
005839257f
@ -64,6 +64,7 @@ import me.ag2s.epublib.domain.FileResourceProvider
|
|||||||
import me.ag2s.epublib.domain.LazyResource
|
import me.ag2s.epublib.domain.LazyResource
|
||||||
import me.ag2s.epublib.domain.Metadata
|
import me.ag2s.epublib.domain.Metadata
|
||||||
import me.ag2s.epublib.domain.Resource
|
import me.ag2s.epublib.domain.Resource
|
||||||
|
import me.ag2s.epublib.domain.TOCReference
|
||||||
import me.ag2s.epublib.epub.EpubWriter
|
import me.ag2s.epublib.epub.EpubWriter
|
||||||
import me.ag2s.epublib.epub.EpubWriterProcessor
|
import me.ag2s.epublib.epub.EpubWriterProcessor
|
||||||
import me.ag2s.epublib.util.ResourceUtil
|
import me.ag2s.epublib.util.ResourceUtil
|
||||||
@ -630,6 +631,7 @@ class ExportBookService : BaseService() {
|
|||||||
} else {
|
} else {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
var parentSection: TOCReference? = null
|
||||||
flow {
|
flow {
|
||||||
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter ->
|
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter ->
|
||||||
emit(chapter)
|
emit(chapter)
|
||||||
@ -667,19 +669,27 @@ class ExportBookService : BaseService() {
|
|||||||
contentModel,
|
contentModel,
|
||||||
"Text/chapter_${index}.html"
|
"Text/chapter_${index}.html"
|
||||||
)
|
)
|
||||||
ExportChapter(title, chapterResource, resources)
|
ExportChapter(title, chapterResource, resources, chapter)
|
||||||
}.collectIndexed { index, exportChapter ->
|
}.collectIndexed { index, exportChapter ->
|
||||||
postEvent(EventBus.EXPORT_BOOK, book.bookUrl)
|
postEvent(EventBus.EXPORT_BOOK, book.bookUrl)
|
||||||
exportProgress[book.bookUrl] = index
|
exportProgress[book.bookUrl] = index
|
||||||
epubBook.resources.addAll(exportChapter.resources)
|
val (title, chapterResource, resources, chapter) = exportChapter
|
||||||
epubBook.addSection(exportChapter.title, exportChapter.chapterResource)
|
epubBook.resources.addAll(resources)
|
||||||
|
if (chapter.isVolume) {
|
||||||
|
parentSection = epubBook.addSection(title, chapterResource)
|
||||||
|
} else if (parentSection == null) {
|
||||||
|
epubBook.addSection(title, chapterResource)
|
||||||
|
} else {
|
||||||
|
epubBook.addSection(parentSection, title, chapterResource)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ExportChapter(
|
data class ExportChapter(
|
||||||
val title: String,
|
val title: String,
|
||||||
val chapterResource: Resource,
|
val chapterResource: Resource,
|
||||||
val resources: ArrayList<Resource>
|
val resources: ArrayList<Resource>,
|
||||||
|
val chapter: BookChapter
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun fixPic(
|
private fun fixPic(
|
||||||
|
Loading…
Reference in New Issue
Block a user