|
|
|
@ -57,49 +57,6 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(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<ArrangeBookViewModel>(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<ArrangeBookViewModel>(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) |
|
|
|
|