This commit is contained in:
kunfei
2022-11-14 20:59:08 +08:00
parent 3cd962629a
commit f57323c76c
4 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ class App : MultiDexApplication() {
2 -> ChineseUtils.preLoad(true, TransType.SIMPLE_TO_TRADITIONAL) 2 -> ChineseUtils.preLoad(true, TransType.SIMPLE_TO_TRADITIONAL)
} }
//同步阅读记录 //同步阅读记录
if (AppWebDav.syncBookProgress) { if (AppConfig.syncBookProgress) {
AppWebDav.downloadAllBookProgress() AppWebDav.downloadAllBookProgress()
} }
} }
@@ -39,7 +39,6 @@ object AppWebDav {
private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip" private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip"
private val bookProgressUrl get() = "${rootWebDavUrl}bookProgress/" private val bookProgressUrl get() = "${rootWebDavUrl}bookProgress/"
private val exportsWebDavUrl get() = "${rootWebDavUrl}books/" private val exportsWebDavUrl get() = "${rootWebDavUrl}books/"
val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true)
var authorization: Authorization? = null var authorization: Authorization? = null
private set private set
@@ -225,7 +224,7 @@ object AppWebDav {
fun uploadBookProgress(book: Book) { fun uploadBookProgress(book: Book) {
val authorization = authorization ?: return val authorization = authorization ?: return
if (!syncBookProgress) return if (!AppConfig.syncBookProgress) return
if (!NetworkUtils.isAvailable()) return if (!NetworkUtils.isAvailable()) return
Coroutine.async { Coroutine.async {
val bookProgress = BookProgress(book) val bookProgress = BookProgress(book)
@@ -239,7 +238,7 @@ object AppWebDav {
fun uploadBookProgress(bookProgress: BookProgress) { fun uploadBookProgress(bookProgress: BookProgress) {
val authorization = authorization ?: return val authorization = authorization ?: return
if (!syncBookProgress) return if (!AppConfig.syncBookProgress) return
if (!NetworkUtils.isAvailable()) return if (!NetworkUtils.isAvailable()) return
Coroutine.async { Coroutine.async {
val json = GSON.toJson(bookProgress) val json = GSON.toJson(bookProgress)
@@ -338,6 +338,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefInt(PreferKey.preDownloadNum, value) appCtx.putPrefInt(PreferKey.preDownloadNum, value)
} }
val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true)
val mediaButtonOnExit get() = appCtx.getPrefBoolean("mediaButtonOnExit", true) val mediaButtonOnExit get() = appCtx.getPrefBoolean("mediaButtonOnExit", true)
val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true) val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
@@ -186,7 +186,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
book: Book, book: Book,
alertSync: ((progress: BookProgress) -> Unit)? = null alertSync: ((progress: BookProgress) -> Unit)? = null
) { ) {
if (!AppWebDav.syncBookProgress) return if (!AppConfig.syncBookProgress) return
execute { execute {
AppWebDav.getBookProgress(book) AppWebDav.getBookProgress(book)
?: throw NoStackTraceException("没有进度") ?: throw NoStackTraceException("没有进度")