diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java index a2e7ea77f3..27a0a739d3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/AppModeDialog.java @@ -85,16 +85,14 @@ public class AppModeDialog { ApplicationMode activeMode = ((OsmandApplication) a.getApplication()).getSettings().getApplicationMode(); final int idx = values.indexOf(activeMode); + OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { - HorizontalScrollView scrollView = ll - .findViewById(R.id.app_modes_scroll_container); + HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container); LinearLayout container = ll.findViewById(R.id.app_modes_content); - int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() - : 0; - scrollView - .scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0); + int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() : 0; + scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0); if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { ll.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { @@ -103,6 +101,7 @@ public class AppModeDialog { } }; ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener); + return ll; } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index c6591eaefa..f2a57df3f8 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -854,10 +854,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener @Override public void onGlobalLayout() { LinearLayout container = ll.findViewById(R.id.app_modes_content); - int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() - + rightTogglePadding : 0; - scrollView - .scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0); + int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() + rightTogglePadding : 0; + scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0); if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { ll.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { @@ -866,7 +864,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener } }; ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener); - }