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() { fun downloadBookProgress() {
Coroutine.async { Coroutine.async {
WebDav(webDavUrl).downloadTo(file.absolutePath, true) if (WebDavHelp.initWebDav()) {
if (file.exists()) { WebDav(webDavUrl).downloadTo(file.absolutePath, true)
val json = file.readText() if (file.exists()) {
GSON.fromJsonArray<BookProgress>(json)?.forEach { val json = file.readText()
App.db.bookDao().upBookProgress( GSON.fromJsonArray<BookProgress>(json)?.forEach {
it.bookUrl, App.db.bookDao().upBookProgress(
it.durChapterIndex, it.bookUrl,
it.durChapterPos, it.durChapterIndex,
it.durChapterTime it.durChapterPos,
) it.durChapterTime
)
}
} }
} }
} }

Loading…
Cancel
Save