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()) } } }