From 2efbf88ffb7579c89c914b284d17d4c6345eaee1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 16 Feb 2021 22:10:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E7=95=8C=E9=9D=A2=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=98=85=E8=AF=BB=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 1 + .../legado/app/ui/welcome/WelcomeActivity.kt | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index cec67c27e..809de0b57 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -7,6 +7,7 @@ * 修复分享内容不对的bug * 优化主题颜色,添加透明度 * rss分类url支持js +* 打开阅读时同步阅读进度 **2021/02/09** * 修复分组内书籍数目少于搜索线程数目,会导致搜索线程数目变低 diff --git a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt index 7a224f3bc..2dc0feb0b 100644 --- a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt @@ -9,6 +9,7 @@ import io.legado.app.data.appDb import io.legado.app.databinding.ActivityWelcomeBinding import io.legado.app.help.AppConfig import io.legado.app.help.coroutine.Coroutine +import io.legado.app.help.storage.BookWebDav import io.legado.app.lib.theme.accentColor import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.main.MainActivity @@ -48,7 +49,25 @@ open class WelcomeActivity : BaseActivity() { else -> null } } - binding.root.postDelayed({ startMainActivity() }, 500) + Coroutine.async(this) { + val books = appDb.bookDao.all + books.forEach { book -> + BookWebDav.getBookProgress(book)?.let { bookProgress -> + if (bookProgress.durChapterIndex > book.durChapterIndex || + (bookProgress.durChapterIndex == book.durChapterIndex && + bookProgress.durChapterPos > book.durChapterPos) + ) { + book.durChapterIndex = bookProgress.durChapterIndex + book.durChapterPos = bookProgress.durChapterPos + book.durChapterTitle = bookProgress.durChapterTitle + book.durChapterTime = bookProgress.durChapterTime + } + } + } + appDb.bookDao.update(*books.toTypedArray()) + }.onFinally { + binding.root.postDelayed({ startMainActivity() }, 300) + } } private fun startMainActivity() {