From bc8b4c1caae974c78494171f5665a76135d6de16 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 17 Feb 2021 08:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=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 --- .../legado/app/ui/welcome/WelcomeActivity.kt | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) 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() {