diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 470ea130d..29918278d 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -57,49 +57,6 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi return super.onPrepareOptionsMenu(menu) } - override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.menu_group_manage -> GroupManageDialog() - .show(supportFragmentManager, "groupManage") - 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() - } - } - return super.onCompatOptionsItemSelected(item) - } - - override fun onMenuItemClick(item: MenuItem?): Boolean { - when (item?.itemId) { - R.id.menu_del_selection -> - alert(titleResource = R.string.sure, messageResource = R.string.sure_del) { - okButton { viewModel.deleteBook(*adapter.selectedBooks.toTypedArray()) } - noButton { } - }.show().applyTint() - } - return false - } - private fun initView() { ATH.applyEdgeEffectColor(recycler_view) recycler_view.layoutManager = LinearLayoutManager(this) @@ -107,7 +64,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi adapter = ArrangeBookAdapter(this, this) recycler_view.adapter = adapter select_action_bar.setMainActionText(R.string.move_to_group) - select_action_bar.inflateMenu(R.menu.arrange_book) + select_action_bar.inflateMenu(R.menu.arrange_book_sel) select_action_bar.setOnMenuItemClickListener(this) select_action_bar.setCallBack(object : SelectActionBar.CallBack { override fun selectAll(selectAll: Boolean) { @@ -149,6 +106,49 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi }) } + override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.menu_group_manage -> GroupManageDialog() + .show(supportFragmentManager, "groupManage") + 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() + } + } + return super.onCompatOptionsItemSelected(item) + } + + override fun onMenuItemClick(item: MenuItem?): Boolean { + when (item?.itemId) { + R.id.menu_del_selection -> + alert(titleResource = R.string.sure, messageResource = R.string.sure_del) { + okButton { viewModel.deleteBook(*adapter.selectedBooks.toTypedArray()) } + noButton { } + }.show().applyTint() + } + return false + } + private fun upMenu() { menu?.findItem(R.id.menu_book_group)?.subMenu?.let { subMenu -> subMenu.removeGroup(R.id.menu_group) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt index 2135e2903..f0fe88f4f 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookAdapter.kt @@ -21,13 +21,11 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : getItems().forEach { selectedBooks.add(it) } - notifyDataSetChanged() - callBack.upSelectCount() } else { selectedBooks.clear() - notifyDataSetChanged() - callBack.upSelectCount() } + notifyDataSetChanged() + callBack.upSelectCount() } fun revertSelection() { @@ -38,6 +36,7 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : selectedBooks.add(it) } } + notifyDataSetChanged() callBack.upSelectCount() } diff --git a/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt b/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt index ca98949e2..23e1c8e17 100644 --- a/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/importbook/ImportBookAdapter.kt @@ -46,13 +46,11 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : selectedUris.add(it.uri.toString()) } } - notifyDataSetChanged() - callBack.upCountView() } else { selectedUris.clear() - notifyDataSetChanged() - callBack.upCountView() } + notifyDataSetChanged() + callBack.upCountView() } fun revertSelection() {