pull/94/head
kunfei 5 years ago
parent 4840b79139
commit 51bf5f8bda
  1. 24
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt
  2. 12
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt

@ -45,9 +45,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
fun enableSelection(sources: LinkedHashSet<BookSource>) { fun enableSelection(sources: LinkedHashSet<BookSource>) {
execute { execute {
val list = ArrayList(sources) val list = arrayListOf<BookSource>()
list.forEach { sources.forEach {
it.enabled = true list.add(it.copy(enabled = true))
} }
App.db.bookSourceDao().update(*list.toTypedArray()) App.db.bookSourceDao().update(*list.toTypedArray())
} }
@ -55,9 +55,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
fun disableSelection(sources: LinkedHashSet<BookSource>) { fun disableSelection(sources: LinkedHashSet<BookSource>) {
execute { execute {
val list = ArrayList(sources) val list = arrayListOf<BookSource>()
list.forEach { sources.forEach {
it.enabled = false list.add(it.copy(enabled = false))
} }
App.db.bookSourceDao().update(*list.toTypedArray()) App.db.bookSourceDao().update(*list.toTypedArray())
} }
@ -65,9 +65,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
fun enableSelectExplore(sources: LinkedHashSet<BookSource>) { fun enableSelectExplore(sources: LinkedHashSet<BookSource>) {
execute { execute {
val list = ArrayList(sources) val list = arrayListOf<BookSource>()
list.forEach { sources.forEach {
it.enabledExplore = true list.add(it.copy(enabledExplore = true))
} }
App.db.bookSourceDao().update(*list.toTypedArray()) App.db.bookSourceDao().update(*list.toTypedArray())
} }
@ -75,9 +75,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
fun disableSelectExplore(sources: LinkedHashSet<BookSource>) { fun disableSelectExplore(sources: LinkedHashSet<BookSource>) {
execute { execute {
val list = ArrayList(sources) val list = arrayListOf<BookSource>()
list.forEach { sources.forEach {
it.enabledExplore = false list.add(it.copy(enabledExplore = false))
} }
App.db.bookSourceDao().update(*list.toTypedArray()) App.db.bookSourceDao().update(*list.toTypedArray())
} }

@ -65,9 +65,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application
fun enableSelection(rules: LinkedHashSet<ReplaceRule>) { fun enableSelection(rules: LinkedHashSet<ReplaceRule>) {
execute { execute {
val list = ArrayList(rules) val list = arrayListOf<ReplaceRule>()
list.forEach { rules.forEach {
it.isEnabled = true list.add(it.copy(isEnabled = true))
} }
App.db.replaceRuleDao().update(*list.toTypedArray()) App.db.replaceRuleDao().update(*list.toTypedArray())
} }
@ -75,9 +75,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application
fun disableSelection(rules: LinkedHashSet<ReplaceRule>) { fun disableSelection(rules: LinkedHashSet<ReplaceRule>) {
execute { execute {
val list = ArrayList(rules) val list = arrayListOf<ReplaceRule>()
list.forEach { rules.forEach {
it.isEnabled = false list.add(it.copy(isEnabled = false))
} }
App.db.replaceRuleDao().update(*list.toTypedArray()) App.db.replaceRuleDao().update(*list.toTypedArray())
} }

Loading…
Cancel
Save