feat: 优化代码

pull/141/head
kunfei 5 years ago
parent ed4b77b313
commit 84d480a833
  1. 4
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookViewModel.kt

@ -147,6 +147,10 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
okButton { viewModel.deleteBook(*adapter.selectedBooks.toTypedArray()) }
noButton { }
}.show().applyTint()
R.id.menu_update_enable ->
viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true)
R.id.menu_update_disable ->
viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true)
}
return false
}

@ -8,6 +8,15 @@ import io.legado.app.data.entities.Book
class ArrangeBookViewModel(application: Application) : BaseViewModel(application) {
fun upCanUpdate(books: Array<Book>, canUpdate: Boolean) {
execute {
books.forEach {
it.canUpdate = canUpdate
}
App.db.bookDao().update(*books)
}
}
fun updateBook(vararg book: Book) {
execute {
App.db.bookDao().update(*book)

Loading…
Cancel
Save