From 51bf5f8bdaa661a35a95ce731b793b2af7b35a9f Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 6 Feb 2020 22:53:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/source/manage/BookSourceViewModel.kt | 24 +++++++++---------- .../ui/replacerule/ReplaceRuleViewModel.kt | 12 +++++----- 2 files changed, 18 insertions(+), 18 deletions(-) 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()) }