From e02f253252c8ff6ff8cfaca68e898f51e3be331b Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 31 Mar 2022 11:24:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/App.kt | 2 +- app/src/main/java/io/legado/app/help/config/AppConfig.kt | 2 -- app/src/main/java/io/legado/app/help/storage/AppWebDav.kt | 4 +++- .../main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 4b76c77e2..ca0ce5494 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -58,7 +58,7 @@ class App : MultiDexApplication() { 2 -> ChineseUtils.s2t("初始化") } //同步阅读记录 - if (AppWebDav.isOk && AppConfig.syncBookProgress) { + if (AppWebDav.syncBookProgress) { AppWebDav.downloadAllBookProgress() } } diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index b069eddb8..25525406f 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -282,8 +282,6 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName) - val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true) - var preDownloadNum get() = appCtx.getPrefInt(PreferKey.preDownloadNum, 10) set(value) { diff --git a/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt index 02538dd73..8898f1f4f 100644 --- a/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt +++ b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt @@ -29,6 +29,8 @@ object AppWebDav { private val bookProgressUrl = "${rootWebDavUrl}bookProgress/" private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip" + val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true) + var isOk = false init { @@ -167,7 +169,7 @@ object AppWebDav { fun uploadBookProgress(book: Book) { if (!isOk) return - if (!AppConfig.syncBookProgress) return + if (!syncBookProgress) return if (!NetworkUtils.isAvailable()) return Coroutine.async { val bookProgress = BookProgress(book) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index c7b95217a..f87b2f259 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -168,7 +168,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { book: Book, alertSync: ((progress: BookProgress) -> Unit)? = null ) { - if (AppConfig.syncBookProgress) + if (AppWebDav.syncBookProgress) execute { AppWebDav.getBookProgress(book) }.onSuccess {