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 2dc0feb0b..20526518a 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 @@ -36,20 +36,6 @@ open class WelcomeActivity : BaseActivity() { private fun init() { 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 books.forEach { book -> BookWebDav.getBookProgress(book)?.let { bookProgress -> @@ -61,13 +47,26 @@ open class WelcomeActivity : BaseActivity() { book.durChapterPos = bookProgress.durChapterPos book.durChapterTitle = bookProgress.durChapterTitle book.durChapterTime = bookProgress.durChapterTime + appDb.bookDao.update(book) } } } - appDb.bookDao.update(*books.toTypedArray()) - }.onFinally { - binding.root.postDelayed({ startMainActivity() }, 300) } + 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 + } + } + binding.root.postDelayed({ startMainActivity() }, 500) } private fun startMainActivity() {