From d628ca4c5ad6155e7b1d00e8736eb77bc54ff5e1 Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Wed, 3 Jul 2019 14:02:02 +0300 Subject: [PATCH] refactoring 2 --- .../osmand/plus/activities/actions/AppModeDialog.java | 9 ++------- .../plus/routepreparationmenu/MapRouteInfoMenu.java | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java index 4dae483949..682353bcb4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java @@ -83,13 +83,8 @@ public class AppModeDialog { final int buttonWidth = (int) a.getResources().getDimension(R.dimen.route_info_modes_height); ApplicationMode activeMode = ((OsmandApplication) a.getApplication()).getSettings().getApplicationMode(); - int modeIndex; - try { - modeIndex = values.indexOf(activeMode); - } catch (Exception e) { - modeIndex = 0; - } - final int scrollSize = (modeIndex + 1) * buttonWidth; + + final int scrollSize = (values.indexOf(activeMode) + 1) * buttonWidth; OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 335d740515..3bf6d414e6 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -846,13 +846,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener final int buttonWidth = (int) mapActivity.getResources().getDimension(R.dimen.route_info_modes_height); final ApplicationMode activeMode = app.getSettings().getApplicationMode(); - int modeIndex; - try { - modeIndex = values.indexOf(activeMode); - } catch (Exception e) { - modeIndex = 0; - } - final int scrollSize = (modeIndex + 1) * buttonWidth + rightTogglePadding; + + final int scrollSize = (values.indexOf(activeMode) + 1) * buttonWidth + rightTogglePadding; OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() { @Override