pull/43/head^2
kunfei 5 years ago
parent d3c2144e36
commit 8d6756202e
  1. 18
      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<String>) { fun enableSelection(ids: LinkedHashSet<String>) {
execute { execute {
App.db.bookSourceDao().enableSection(*ids.toTypedArray()) ids.forEach {
App.db.bookSourceDao().enableSection(it)
}
} }
} }
fun disableSelection(ids: LinkedHashSet<String>) { fun disableSelection(ids: LinkedHashSet<String>) {
execute { execute {
App.db.bookSourceDao().disableSection(*ids.toTypedArray()) ids.forEach {
App.db.bookSourceDao().disableSection(it)
}
} }
} }
fun delSelection(ids: LinkedHashSet<String>) { fun delSelection(ids: LinkedHashSet<String>) {
execute { 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 val sources = App.db.bookSourceDao().noGroup
sources.map { source -> sources.map { source ->
source.bookSourceGroup = group 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) it.add(newGroup)
source.bookSourceGroup = TextUtils.join(",", it) 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) it.remove(group)
source.bookSourceGroup = TextUtils.join(",", it) source.bookSourceGroup = TextUtils.join(",", it)
} }
App.db.bookSourceDao().update(source)
} }
App.db.bookSourceDao().update(*sources.toTypedArray())
} }
} }
} }

Loading…
Cancel
Save