|
|
@ -7,6 +7,7 @@ import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.BaseViewModel |
|
|
|
import io.legado.app.base.BaseViewModel |
|
|
|
import io.legado.app.constant.AppPattern |
|
|
|
import io.legado.app.constant.AppPattern |
|
|
|
|
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.help.storage.WebDavHelp |
|
|
|
import io.legado.app.help.storage.WebDavHelp |
|
|
@ -39,15 +40,17 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
val content = getAllContents(book) |
|
|
|
val content = getAllContents(book) |
|
|
|
DocumentUtils.createFileIfNotExist(doc, filename) |
|
|
|
DocumentUtils.createFileIfNotExist(doc, filename) |
|
|
|
?.writeText(context, content) |
|
|
|
?.writeText(context, content) |
|
|
|
//写出文件到cache目录 |
|
|
|
if(App.INSTANCE.getPrefBoolean(PreferKey.webDavExport,false)) { |
|
|
|
FileUtils.createFileIfNotExist( |
|
|
|
//写出文件到cache目录 |
|
|
|
File(FileUtils.getCachePath()), |
|
|
|
FileUtils.createFileIfNotExist( |
|
|
|
filename |
|
|
|
File(FileUtils.getCachePath()), |
|
|
|
).writeText(content) |
|
|
|
filename |
|
|
|
//导出到webdav |
|
|
|
).writeText(content) |
|
|
|
WebDavHelp.exportWebDav(FileUtils.getCachePath(), filename) |
|
|
|
//导出到webdav |
|
|
|
//上传完删除cache文件 |
|
|
|
WebDavHelp.exportWebDav(FileUtils.getCachePath(), filename) |
|
|
|
FileUtils.deleteFile("${FileUtils.getCachePath()}${File.separator}${filename}") |
|
|
|
//上传完删除cache文件 |
|
|
|
|
|
|
|
FileUtils.deleteFile("${FileUtils.getCachePath()}${File.separator}${filename}") |
|
|
|
|
|
|
|
} |
|
|
|
App.db.bookChapterDao().getChapterList(book.bookUrl).forEach { chapter -> |
|
|
|
App.db.bookChapterDao().getChapterList(book.bookUrl).forEach { chapter -> |
|
|
|
BookHelp.getContent(book, chapter).let { content -> |
|
|
|
BookHelp.getContent(book, chapter).let { content -> |
|
|
|
content?.split("\n")?.forEachIndexed { index, text -> |
|
|
|
content?.split("\n")?.forEachIndexed { index, text -> |
|
|
@ -76,7 +79,9 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
val filename = "${book.name} by ${book.author}.txt" |
|
|
|
val filename = "${book.name} by ${book.author}.txt" |
|
|
|
FileUtils.createFileIfNotExist(file, filename) |
|
|
|
FileUtils.createFileIfNotExist(file, filename) |
|
|
|
.writeText(getAllContents(book)) |
|
|
|
.writeText(getAllContents(book)) |
|
|
|
WebDavHelp.exportWebDav(file.absolutePath, filename)//导出到webdav |
|
|
|
if(App.INSTANCE.getPrefBoolean(PreferKey.webDavExport,false)) { |
|
|
|
|
|
|
|
WebDavHelp.exportWebDav(file.absolutePath, filename)//导出到webdav |
|
|
|
|
|
|
|
} |
|
|
|
App.db.bookChapterDao().getChapterList(book.bookUrl).forEach { chapter -> |
|
|
|
App.db.bookChapterDao().getChapterList(book.bookUrl).forEach { chapter -> |
|
|
|
BookHelp.getContent(book, chapter).let { content -> |
|
|
|
BookHelp.getContent(book, chapter).let { content -> |
|
|
|
content?.split("\n")?.forEachIndexed { index, text -> |
|
|
|
content?.split("\n")?.forEachIndexed { index, text -> |
|
|
|