|
|
@ -183,13 +183,13 @@ class BookshelfManageActivity : |
|
|
|
when (item?.itemId) { |
|
|
|
when (item?.itemId) { |
|
|
|
R.id.menu_del_selection -> |
|
|
|
R.id.menu_del_selection -> |
|
|
|
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { |
|
|
|
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { |
|
|
|
okButton { viewModel.deleteBook(*adapter.selectedBooks()) } |
|
|
|
okButton { viewModel.deleteBook(*adapter.selection.toTypedArray()) } |
|
|
|
noButton() |
|
|
|
noButton() |
|
|
|
} |
|
|
|
} |
|
|
|
R.id.menu_update_enable -> |
|
|
|
R.id.menu_update_enable -> |
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks(), true) |
|
|
|
viewModel.upCanUpdate(adapter.selection, true) |
|
|
|
R.id.menu_update_disable -> |
|
|
|
R.id.menu_update_disable -> |
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks(), false) |
|
|
|
viewModel.upCanUpdate(adapter.selection, false) |
|
|
|
R.id.menu_add_to_group -> selectGroup(addToGroupRequestCode, 0) |
|
|
|
R.id.menu_add_to_group -> selectGroup(addToGroupRequestCode, 0) |
|
|
|
R.id.menu_change_source -> showDialogFragment<SourcePickerDialog>() |
|
|
|
R.id.menu_change_source -> showDialogFragment<SourcePickerDialog>() |
|
|
|
} |
|
|
|
} |
|
|
@ -213,30 +213,29 @@ class BookshelfManageActivity : |
|
|
|
|
|
|
|
|
|
|
|
override fun upGroup(requestCode: Int, groupId: Long) { |
|
|
|
override fun upGroup(requestCode: Int, groupId: Long) { |
|
|
|
when (requestCode) { |
|
|
|
when (requestCode) { |
|
|
|
groupRequestCode -> { |
|
|
|
groupRequestCode -> adapter.selection.let { books -> |
|
|
|
val books = arrayListOf<Book>() |
|
|
|
val array = Array(books.size) { |
|
|
|
adapter.selectedBooks().forEach { |
|
|
|
books[it].copy(group = groupId) |
|
|
|
books.add(it.copy(group = groupId)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
viewModel.updateBook(*books.toTypedArray()) |
|
|
|
viewModel.updateBook(*array) |
|
|
|
} |
|
|
|
} |
|
|
|
adapter.groupRequestCode -> { |
|
|
|
adapter.groupRequestCode -> { |
|
|
|
adapter.actionItem?.let { |
|
|
|
adapter.actionItem?.let { |
|
|
|
viewModel.updateBook(it.copy(group = groupId)) |
|
|
|
viewModel.updateBook(it.copy(group = groupId)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
addToGroupRequestCode -> { |
|
|
|
addToGroupRequestCode -> adapter.selection.let { books -> |
|
|
|
val books = arrayListOf<Book>() |
|
|
|
val array = Array(books.size) { index -> |
|
|
|
adapter.selectedBooks().forEach { |
|
|
|
val book = books[index] |
|
|
|
books.add(it.copy(group = it.group or groupId)) |
|
|
|
book.copy(group = book.group or groupId) |
|
|
|
} |
|
|
|
} |
|
|
|
viewModel.updateBook(*books.toTypedArray()) |
|
|
|
viewModel.updateBook(*array) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun upSelectCount() { |
|
|
|
override fun upSelectCount() { |
|
|
|
binding.selectActionBar.upCountView(adapter.selectedBooks().size, adapter.getItems().size) |
|
|
|
binding.selectActionBar.upCountView(adapter.selection.size, adapter.getItems().size) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun updateBook(vararg book: Book) { |
|
|
|
override fun updateBook(vararg book: Book) { |
|
|
@ -252,7 +251,7 @@ class BookshelfManageActivity : |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun sourceOnClick(source: BookSource) { |
|
|
|
override fun sourceOnClick(source: BookSource) { |
|
|
|
viewModel.changeSource(adapter.selectedBooks(), source) |
|
|
|
viewModel.changeSource(adapter.selection, source) |
|
|
|
viewModel.batchChangeSourceState.value = true |
|
|
|
viewModel.batchChangeSourceState.value = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|