pull/32/head
kunfei 5 years ago
parent 2414f38afc
commit b9aab12513
  1. 3
      app/src/main/java/io/legado/app/data/dao/ReplaceRuleDao.kt
  2. 1
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  3. 6
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt

@ -35,6 +35,9 @@ interface ReplaceRuleDao {
@Query("update replace_rules set isEnabled = 1 where id in (:ids)") @Query("update replace_rules set isEnabled = 1 where id in (:ids)")
fun enableSection(vararg ids: Long) fun enableSection(vararg ids: Long)
@Query("update replace_rules set isEnabled = 0 where id in (:ids)")
fun disableSection(vararg ids: Long)
@Query( @Query(
"""SELECT * FROM replace_rules WHERE isEnabled = 1 """SELECT * FROM replace_rules WHERE isEnabled = 1
AND (scope LIKE '%' || :scope || '%' or scope = null or scope = '')""" AND (scope LIKE '%' || :scope || '%' or scope = null or scope = '')"""

@ -63,6 +63,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
R.id.menu_select_all -> adapter.selectAll() R.id.menu_select_all -> adapter.selectAll()
R.id.menu_revert_selection -> adapter.revertSelection() R.id.menu_revert_selection -> adapter.revertSelection()
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selectedIds) R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selectedIds)
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selectedIds)
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }

@ -45,6 +45,12 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application
} }
} }
fun disableSelection(ids: LinkedHashSet<Long>) {
execute {
App.db.replaceRuleDao().disableSection(*ids.toLongArray())
}
}
fun addGroup(group: String) { fun addGroup(group: String) {
execute { execute {
val sources = App.db.replaceRuleDao().noGroup val sources = App.db.replaceRuleDao().noGroup

Loading…
Cancel
Save