启动界面同步阅读进度

pull/854/head
gedoor 4 years ago
parent d84bfe2c73
commit 2efbf88ffb
  1. 1
      app/src/main/assets/updateLog.md
  2. 21
      app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt

@ -7,6 +7,7 @@
* 修复分享内容不对的bug
* 优化主题颜色,添加透明度
* rss分类url支持js
* 打开阅读时同步阅读进度
**2021/02/09**
* 修复分组内书籍数目少于搜索线程数目,会导致搜索线程数目变低

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

Loading…
Cancel
Save