Skip to content

Commit

Permalink
fix: Don't show "Remove tab" menu if there are no tabs
Browse files Browse the repository at this point in the history
Prevents a crash that would otherwise occur.
  • Loading branch information
nikclayton committed Dec 13, 2024
1 parent a66da06 commit adec880
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/main/java/app/pachli/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
override fun onPrepareMenu(menu: Menu) {
super<BottomSheetActivity>.onPrepareMenu(menu)

menu.findItem(R.id.action_remove_tab).isVisible = tabAdapter.tabs.getOrNull(binding.viewPager.currentItem)?.timeline != Timeline.Home
menu.findItem(R.id.action_remove_tab).isVisible = tabAdapter.tabs.getOrNull(binding.viewPager.currentItem)?.let {
it.timeline != Timeline.Home
} ?: false

// If the main toolbar is hidden then there's no space in the top/bottomNav to show
// the menu items as icons, so forceably disable them
Expand Down

0 comments on commit adec880

Please sign in to comment.