diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 58618d88c..ec5c50020 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -45,9 +45,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) fun enableSelection(sources: LinkedHashSet) { execute { - val list = ArrayList(sources) - list.forEach { - it.enabled = true + val list = arrayListOf() + sources.forEach { + list.add(it.copy(enabled = true)) } App.db.bookSourceDao().update(*list.toTypedArray()) } @@ -55,9 +55,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) fun disableSelection(sources: LinkedHashSet) { execute { - val list = ArrayList(sources) - list.forEach { - it.enabled = false + val list = arrayListOf() + sources.forEach { + list.add(it.copy(enabled = false)) } App.db.bookSourceDao().update(*list.toTypedArray()) } @@ -65,9 +65,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) fun enableSelectExplore(sources: LinkedHashSet) { execute { - val list = ArrayList(sources) - list.forEach { - it.enabledExplore = true + val list = arrayListOf() + sources.forEach { + list.add(it.copy(enabledExplore = true)) } App.db.bookSourceDao().update(*list.toTypedArray()) } @@ -75,9 +75,9 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) fun disableSelectExplore(sources: LinkedHashSet) { execute { - val list = ArrayList(sources) - list.forEach { - it.enabledExplore = false + val list = arrayListOf() + sources.forEach { + list.add(it.copy(enabledExplore = false)) } App.db.bookSourceDao().update(*list.toTypedArray()) } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt index 6390d69e7..c54f126d8 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt @@ -65,9 +65,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application fun enableSelection(rules: LinkedHashSet) { execute { - val list = ArrayList(rules) - list.forEach { - it.isEnabled = true + val list = arrayListOf() + rules.forEach { + list.add(it.copy(isEnabled = true)) } App.db.replaceRuleDao().update(*list.toTypedArray()) } @@ -75,9 +75,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application fun disableSelection(rules: LinkedHashSet) { execute { - val list = ArrayList(rules) - list.forEach { - it.isEnabled = false + val list = arrayListOf() + rules.forEach { + list.add(it.copy(isEnabled = false)) } App.db.replaceRuleDao().update(*list.toTypedArray()) }