From 8d6756202ef30ff11b82c2dc1927c5f456209f57 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 31 Oct 2019 09:32:44 +0800 Subject: [PATCH] up --- .../book/source/manage/BookSourceViewModel.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 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 7a3b5bb91..598167e43 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 @@ -42,19 +42,25 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) fun enableSelection(ids: LinkedHashSet) { execute { - App.db.bookSourceDao().enableSection(*ids.toTypedArray()) + ids.forEach { + App.db.bookSourceDao().enableSection(it) + } } } fun disableSelection(ids: LinkedHashSet) { execute { - App.db.bookSourceDao().disableSection(*ids.toTypedArray()) + ids.forEach { + App.db.bookSourceDao().disableSection(it) + } } } fun delSelection(ids: LinkedHashSet) { execute { - App.db.bookSourceDao().delSection(*ids.toTypedArray()) + ids.forEach { + App.db.bookSourceDao().delSection(it) + } } } @@ -63,8 +69,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) val sources = App.db.bookSourceDao().noGroup sources.map { source -> source.bookSourceGroup = group + App.db.bookSourceDao().update(source) } - App.db.bookSourceDao().update(*sources.toTypedArray()) } } @@ -78,8 +84,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) it.add(newGroup) source.bookSourceGroup = TextUtils.join(",", it) } + App.db.bookSourceDao().update(source) } - App.db.bookSourceDao().update(*sources.toTypedArray()) } } @@ -92,8 +98,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) it.remove(group) source.bookSourceGroup = TextUtils.join(",", it) } + App.db.bookSourceDao().update(source) } - App.db.bookSourceDao().update(*sources.toTypedArray()) } } }