启动时同步阅读进度

pull/854/head
gedoor 4 years ago
parent 2efbf88ffb
commit bc8b4c1caa
  1. 33
      app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt

@ -36,20 +36,6 @@ open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
private fun init() { private fun init() {
Coroutine.async { Coroutine.async {
appDb.cacheDao.clearDeadline(System.currentTimeMillis())
//清除过期数据
if (getPrefBoolean(PreferKey.autoClearExpired, true)) {
appDb.searchBookDao
.clearExpired(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1))
}
//初始化简繁转换引擎
when (AppConfig.chineseConverterType) {
1 -> HanLP.convertToSimplifiedChinese("初始化")
2 -> HanLP.convertToTraditionalChinese("初始化")
else -> null
}
}
Coroutine.async(this) {
val books = appDb.bookDao.all val books = appDb.bookDao.all
books.forEach { book -> books.forEach { book ->
BookWebDav.getBookProgress(book)?.let { bookProgress -> BookWebDav.getBookProgress(book)?.let { bookProgress ->
@ -61,13 +47,26 @@ open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
book.durChapterPos = bookProgress.durChapterPos book.durChapterPos = bookProgress.durChapterPos
book.durChapterTitle = bookProgress.durChapterTitle book.durChapterTitle = bookProgress.durChapterTitle
book.durChapterTime = bookProgress.durChapterTime book.durChapterTime = bookProgress.durChapterTime
appDb.bookDao.update(book)
}
} }
} }
} }
appDb.bookDao.update(*books.toTypedArray()) Coroutine.async {
}.onFinally { appDb.cacheDao.clearDeadline(System.currentTimeMillis())
binding.root.postDelayed({ startMainActivity() }, 300) //清除过期数据
if (getPrefBoolean(PreferKey.autoClearExpired, true)) {
appDb.searchBookDao
.clearExpired(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1))
}
//初始化简繁转换引擎
when (AppConfig.chineseConverterType) {
1 -> HanLP.convertToSimplifiedChinese("初始化")
2 -> HanLP.convertToTraditionalChinese("初始化")
else -> null
}
} }
binding.root.postDelayed({ startMainActivity() }, 500)
} }
private fun startMainActivity() { private fun startMainActivity() {

Loading…
Cancel
Save