|
|
|
@ -115,25 +115,21 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
R.id.menu_all -> { |
|
|
|
|
title_bar.subtitle = item.title |
|
|
|
|
groupId = -1 |
|
|
|
|
adapter.selectedBooks.clear() |
|
|
|
|
initBookData() |
|
|
|
|
} |
|
|
|
|
R.id.menu_local -> { |
|
|
|
|
title_bar.subtitle = item.title |
|
|
|
|
groupId = -2 |
|
|
|
|
adapter.selectedBooks.clear() |
|
|
|
|
initBookData() |
|
|
|
|
} |
|
|
|
|
R.id.menu_audio -> { |
|
|
|
|
title_bar.subtitle = item.title |
|
|
|
|
groupId = -3 |
|
|
|
|
adapter.selectedBooks.clear() |
|
|
|
|
initBookData() |
|
|
|
|
} |
|
|
|
|
else -> if (item.groupId == R.id.menu_group) { |
|
|
|
|
title_bar.subtitle = item.title |
|
|
|
|
groupId = item.itemId |
|
|
|
|
adapter.selectedBooks.clear() |
|
|
|
|
initBookData() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -144,13 +140,13 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
when (item?.itemId) { |
|
|
|
|
R.id.menu_del_selection -> |
|
|
|
|
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { |
|
|
|
|
okButton { viewModel.deleteBook(*adapter.selectedBooks.toTypedArray()) } |
|
|
|
|
okButton { viewModel.deleteBook(*adapter.selectedBooks()) } |
|
|
|
|
noButton { } |
|
|
|
|
}.show().applyTint() |
|
|
|
|
R.id.menu_update_enable -> |
|
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), true) |
|
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks(), true) |
|
|
|
|
R.id.menu_update_disable -> |
|
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks.toTypedArray(), false) |
|
|
|
|
viewModel.upCanUpdate(adapter.selectedBooks(), false) |
|
|
|
|
R.id.menu_add_to_group -> selectGroup(0, addToGroupRequestCode) |
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
@ -173,7 +169,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
when (requestCode) { |
|
|
|
|
groupRequestCode -> { |
|
|
|
|
val books = arrayListOf<Book>() |
|
|
|
|
adapter.selectedBooks.forEach { |
|
|
|
|
adapter.selectedBooks().forEach { |
|
|
|
|
books.add(it.copy(group = groupId)) |
|
|
|
|
} |
|
|
|
|
viewModel.updateBook(*books.toTypedArray()) |
|
|
|
@ -185,7 +181,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
} |
|
|
|
|
addToGroupRequestCode -> { |
|
|
|
|
val books = arrayListOf<Book>() |
|
|
|
|
adapter.selectedBooks.forEach { |
|
|
|
|
adapter.selectedBooks().forEach { |
|
|
|
|
books.add(it.copy(group = it.group or groupId)) |
|
|
|
|
} |
|
|
|
|
viewModel.updateBook(*books.toTypedArray()) |
|
|
|
@ -194,7 +190,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun upSelectCount() { |
|
|
|
|
select_action_bar.upCountView(adapter.selectedBooks.size, adapter.getItems().size) |
|
|
|
|
select_action_bar.upCountView(adapter.selectedBooks().size, adapter.getItems().size) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun deleteBook(book: Book) { |
|
|
|
|