feat: 优化代码

pull/133/head
kunfei 5 years ago
parent 656fe45efb
commit 4f200ec3bb
  1. 22
      app/src/main/java/io/legado/app/help/storage/SyncBookProgress.kt

@ -30,16 +30,18 @@ object SyncBookProgress {
fun downloadBookProgress() {
Coroutine.async {
WebDav(webDavUrl).downloadTo(file.absolutePath, true)
if (file.exists()) {
val json = file.readText()
GSON.fromJsonArray<BookProgress>(json)?.forEach {
App.db.bookDao().upBookProgress(
it.bookUrl,
it.durChapterIndex,
it.durChapterPos,
it.durChapterTime
)
if (WebDavHelp.initWebDav()) {
WebDav(webDavUrl).downloadTo(file.absolutePath, true)
if (file.exists()) {
val json = file.readText()
GSON.fromJsonArray<BookProgress>(json)?.forEach {
App.db.bookDao().upBookProgress(
it.bookUrl,
it.durChapterIndex,
it.durChapterPos,
it.durChapterTime
)
}
}
}
}

Loading…
Cancel
Save