Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Nov 14, 2022
1 parent e06fe6f commit e8a97c1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/io/legado/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class App : MultiDexApplication() {
2 -> ChineseUtils.preLoad(true, TransType.SIMPLE_TO_TRADITIONAL)
}
//同步阅读记录
if (AppWebDav.syncBookProgress) {
if (AppConfig.syncBookProgress) {
AppWebDav.downloadAllBookProgress()
}
}
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/io/legado/app/help/AppWebDav.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ object AppWebDav {
private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip"
private val bookProgressUrl get() = "${rootWebDavUrl}bookProgress/"
private val exportsWebDavUrl get() = "${rootWebDavUrl}books/"
val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true)

var authorization: Authorization? = null
private set
Expand Down Expand Up @@ -225,7 +224,7 @@ object AppWebDav {

fun uploadBookProgress(book: Book) {
val authorization = authorization ?: return
if (!syncBookProgress) return
if (!AppConfig.syncBookProgress) return
if (!NetworkUtils.isAvailable()) return
Coroutine.async {
val bookProgress = BookProgress(book)
Expand All @@ -239,7 +238,7 @@ object AppWebDav {

fun uploadBookProgress(bookProgress: BookProgress) {
val authorization = authorization ?: return
if (!syncBookProgress) return
if (!AppConfig.syncBookProgress) return
if (!NetworkUtils.isAvailable()) return
Coroutine.async {
val json = GSON.toJson(bookProgress)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/legado/app/help/config/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefInt(PreferKey.preDownloadNum, value)
}

val syncBookProgress get() = appCtx.getPrefBoolean(PreferKey.syncBookProgress, true)

val mediaButtonOnExit get() = appCtx.getPrefBoolean("mediaButtonOnExit", true)

val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
book: Book,
alertSync: ((progress: BookProgress) -> Unit)? = null
) {
if (!AppWebDav.syncBookProgress) return
if (!AppConfig.syncBookProgress) return
execute {
AppWebDav.getBookProgress(book)
?: throw NoStackTraceException("没有进度")
Expand Down

0 comments on commit e8a97c1

Please sign in to comment.