Skip to content

Commit

Permalink
Hide overflow menu if the list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
cooltey committed Nov 20, 2023
1 parent f79227e commit 3497bfb
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ class TalkTemplatesFragment : Fragment(), MenuProvider {
inflater.inflate(R.menu.menu_talk_templates, menu)
}

override fun onPrepareMenu(menu: Menu) {
super.onPrepareMenu(menu)
menu.findItem(R.id.menu_overflow).isVisible = viewModel.talkTemplatesList.isNotEmpty()
}

override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
return when (menuItem.itemId) {
R.id.menu_new_message -> {
Expand Down Expand Up @@ -146,6 +151,7 @@ class TalkTemplatesFragment : Fragment(), MenuProvider {

private fun onSuccess() {
setRecyclerView()
requireActivity().invalidateOptionsMenu()
binding.talkTemplatesEmptyContainer.isVisible = viewModel.talkTemplatesList.isEmpty()
binding.talkTemplatesErrorView.visibility = View.GONE
binding.talkTemplatesProgressBar.visibility = View.GONE
Expand Down

0 comments on commit 3497bfb

Please sign in to comment.