pull/801/head
gedoor 4 years ago
parent 8234021310
commit fd92efdb1b
  1. 4
      app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt

@ -63,6 +63,10 @@ interface SearchBookDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg searchBook: SearchBook): List<Long> fun insert(vararg searchBook: SearchBook): List<Long>
@Query("delete from searchBooks where name = :name and author = :author")
fun clear(name: String, author: String)
@Query("delete from searchBooks where time < :time") @Query("delete from searchBooks where time < :time")
fun clearExpired(time: Long) fun clearExpired(time: Long)
} }

@ -84,10 +84,10 @@ class ChangeSourceDialog : BaseDialogFragment(),
binding.toolBar.inflateMenu(R.menu.change_source) binding.toolBar.inflateMenu(R.menu.change_source)
binding.toolBar.menu.applyTint(requireContext()) binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener(this) binding.toolBar.setOnMenuItemClickListener(this)
binding.toolBar.menu.findItem(R.id.menu_load_info)?.isChecked = binding.toolBar.menu.findItem(R.id.menu_load_info)
AppConfig.changeSourceLoadInfo ?.isChecked = AppConfig.changeSourceLoadInfo
binding.toolBar.menu.findItem(R.id.menu_load_toc)?.isChecked = AppConfig.changeSourceLoadToc binding.toolBar.menu.findItem(R.id.menu_load_toc)
?.isChecked = AppConfig.changeSourceLoadToc
} }
private fun initRecyclerView() { private fun initRecyclerView() {

@ -99,6 +99,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
private fun startSearch() { private fun startSearch() {
execute { execute {
App.db.searchBookDao.clear(name, author)
bookSourceList.clear() bookSourceList.clear()
if (searchGroup.isBlank()) { if (searchGroup.isBlank()) {
bookSourceList.addAll(App.db.bookSourceDao.allEnabled) bookSourceList.addAll(App.db.bookSourceDao.allEnabled)

Loading…
Cancel
Save