Skip to content

Commit

Permalink
try to fix crash on menu open
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosKozak committed Dec 16, 2024
1 parent 77a3fe7 commit 49ce3f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/app/aaps/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
val result = super.onMenuOpened(featureId, menu)
menu.findItem(R.id.nav_treatments)?.isEnabled = profileFunction.getProfile() != null
if (binding.mainPager.currentItem >= 0) {
val plugin = (binding.mainPager.adapter as TabPageAdapter).getPluginAt(binding.mainPager.currentItem)
val plugin = (binding.mainPager.adapter as TabPageAdapter?)?.getPluginAt(binding.mainPager.currentItem) ?: return result
this.menu?.findItem(R.id.nav_plugin_preferences)?.title = rh.gs(R.string.nav_preferences_plugin, plugin.name)
pluginPreferencesMenuItem?.isEnabled = (binding.mainPager.adapter as TabPageAdapter).getPluginAt(binding.mainPager.currentItem).preferencesId != PluginDescription.PREFERENCE_NONE
}
Expand Down

0 comments on commit 49ce3f7

Please sign in to comment.