diff --git a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt index 7afa40839..779cfd1e2 100644 --- a/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt @@ -59,5 +59,5 @@ interface SearchBookDao { fun insert(vararg searchBook: SearchBook): List @Query("delete from searchBooks where time < :time") - fun clearOld(time: Long) + fun clearExpired(time: Long) } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index a4ede48c0..57c368a2c 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -52,17 +52,20 @@ class MainActivity : VMBaseActivity(R.layout.activity_main), override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) upVersion() + //初始化简繁转换引擎 when (AppConfig.chineseConverterType) { 1 -> ZhConverterUtil.toSimple("初始化") 2 -> ZhConverterUtil.toTraditional("初始化") } + //自动更新书籍 if (AppConfig.autoRefreshBook) { view_pager_main.postDelayed({ viewModel.upChapterList() }, 1000) } + //清楚过期数据 view_pager_main.postDelayed({ - viewModel.clearDb() + viewModel.clearExpiredData() }, 3000) } diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index 29fa339ea..1a0652bae 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -54,9 +54,10 @@ class MainViewModel(application: Application) : BaseViewModel(application) { } } - fun clearDb() { + fun clearExpiredData() { execute { - App.db.searchBookDao().clearOld(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)) + App.db.searchBookDao() + .clearExpired(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)) } }