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() {