From 83324c97a7e50196d042572878bd38cbcdf34805 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 7 Jan 2021 11:16:41 +0100 Subject: [PATCH] prevent ArrayIndexOutOfBoundsException --- .../main/java/info/nightscout/androidaps/MainActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index 951638d9ae..c2b7ae6073 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -275,8 +275,10 @@ class MainActivity : NoSplashAppCompatActivity() { } private fun setPluginPreferenceMenuName() { - val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem) - this.menu?.findItem(R.id.nav_plugin_preferences)?.title = resourceHelper.gs(R.string.nav_preferences_plugin, plugin.name) + if (main_pager.currentItem > 0) { + val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem) + this.menu?.findItem(R.id.nav_plugin_preferences)?.title = resourceHelper.gs(R.string.nav_preferences_plugin, plugin.name) + } } override fun onCreateOptionsMenu(menu: Menu): Boolean {