|
|
@ -137,7 +137,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getAllContents( |
|
|
|
private suspend fun getAllContents( |
|
|
|
scope: CoroutineScope, |
|
|
|
scope: CoroutineScope, |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|
append: (text: String, srcList: ArrayList<Triple<String, Int, String>>?) -> Unit |
|
|
|
append: (text: String, srcList: ArrayList<Triple<String, Int, String>>?) -> Unit |
|
|
@ -214,7 +214,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("BlockingMethodInNonBlockingContext") |
|
|
|
@Suppress("BlockingMethodInNonBlockingContext") |
|
|
|
private fun exportEpub(scope: CoroutineScope, doc: DocumentFile, book: Book) { |
|
|
|
private suspend fun exportEpub(scope: CoroutineScope, doc: DocumentFile, book: Book) { |
|
|
|
val filename = "${getExportFileName(book)}.epub" |
|
|
|
val filename = "${getExportFileName(book)}.epub" |
|
|
|
DocumentUtils.delete(doc, filename) |
|
|
|
DocumentUtils.delete(doc, filename) |
|
|
|
val epubBook = EpubBook() |
|
|
|
val epubBook = EpubBook() |
|
|
@ -237,7 +237,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun exportEpub(scope: CoroutineScope, file: File, book: Book) { |
|
|
|
private suspend fun exportEpub(scope: CoroutineScope, file: File, book: Book) { |
|
|
|
val filename = "${getExportFileName(book)}.epub" |
|
|
|
val filename = "${getExportFileName(book)}.epub" |
|
|
|
val epubBook = EpubBook() |
|
|
|
val epubBook = EpubBook() |
|
|
|
epubBook.version = "2.0" |
|
|
|
epubBook.version = "2.0" |
|
|
@ -252,6 +252,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
val bookFile = FileUtils.createFileWithReplace(bookPath) |
|
|
|
val bookFile = FileUtils.createFileWithReplace(bookPath) |
|
|
|
//设置正文 |
|
|
|
//设置正文 |
|
|
|
setEpubContent(scope, contentModel, book, epubBook) |
|
|
|
setEpubContent(scope, contentModel, book, epubBook) |
|
|
|
|
|
|
|
@Suppress("BlockingMethodInNonBlockingContext") |
|
|
|
EpubWriter().write(epubBook, FileOutputStream(bookFile)) |
|
|
|
EpubWriter().write(epubBook, FileOutputStream(bookFile)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -404,7 +405,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun setEpubContent( |
|
|
|
private suspend fun setEpubContent( |
|
|
|
scope: CoroutineScope, |
|
|
|
scope: CoroutineScope, |
|
|
|
contentModel: String, |
|
|
|
contentModel: String, |
|
|
|
book: Book, |
|
|
|
book: Book, |
|
|
|