pull/1751/head
kunfei 3 years ago
parent 4e4a75cb3b
commit 0b7d745f66
  1. 2
      app/src/main/java/io/legado/app/App.kt
  2. 11
      app/src/main/java/io/legado/app/help/BookHelp.kt
  3. 5
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -14,6 +14,7 @@ import io.legado.app.constant.AppConst.channelIdReadAloud
import io.legado.app.constant.AppConst.channelIdWeb
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.help.BookHelp
import io.legado.app.help.CrashHandler
import io.legado.app.help.LifecycleHelp
import io.legado.app.help.RuleBigDataHelp
@ -52,6 +53,7 @@ class App : MultiDexApplication() {
appDb.searchBookDao.clearExpired(clearTime)
}
RuleBigDataHelp.clearInvalid()
BookHelp.clearInvalidCache()
//初始化简繁转换引擎
when (AppConfig.chineseConverterType) {
1 -> ChineseUtils.t2s("初始化")

@ -6,14 +6,11 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.model.localBook.LocalBook
import io.legado.app.utils.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO
import org.apache.commons.text.similarity.JaccardSimilarity
import splitties.init.appCtx
import java.io.File
@ -44,8 +41,8 @@ object BookHelp {
/**
* 清除已删除书的缓存
*/
fun clearRemovedCache() {
Coroutine.async {
suspend fun clearInvalidCache() {
withContext(IO) {
val bookFolderNames = appDb.bookDao.all.map {
it.getFolderName()
}

@ -22,6 +22,7 @@ import io.legado.app.databinding.ActivityMainBinding
import io.legado.app.help.BookHelp
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.LocalConfig
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.storage.Backup
import io.legado.app.lib.theme.elevation
import io.legado.app.lib.theme.primaryColor
@ -175,7 +176,9 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
override fun onDestroy() {
super.onDestroy()
BookHelp.clearRemovedCache()
Coroutine.async {
BookHelp.clearInvalidCache()
}
}
override fun observeLiveBus() {

Loading…
Cancel
Save