formatting

This commit is contained in:
madwasp79 2019-07-17 12:55:42 +03:00
parent a3395838df
commit 0242553eea
2 changed files with 7 additions and 11 deletions

View file

@ -85,16 +85,14 @@ public class AppModeDialog {
ApplicationMode activeMode = ((OsmandApplication) a.getApplication()).getSettings().getApplicationMode(); ApplicationMode activeMode = ((OsmandApplication) a.getApplication()).getSettings().getApplicationMode();
final int idx = values.indexOf(activeMode); final int idx = values.indexOf(activeMode);
OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() { OnGlobalLayoutListener globalListener = new OnGlobalLayoutListener() {
@Override @Override
public void onGlobalLayout() { public void onGlobalLayout() {
HorizontalScrollView scrollView = ll HorizontalScrollView scrollView = ll.findViewById(R.id.app_modes_scroll_container);
.findViewById(R.id.app_modes_scroll_container);
LinearLayout container = ll.findViewById(R.id.app_modes_content); LinearLayout container = ll.findViewById(R.id.app_modes_content);
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() : 0;
: 0; scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
scrollView
.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this); ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else { } else {
@ -103,6 +101,7 @@ public class AppModeDialog {
} }
}; };
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener); ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);
return ll; return ll;
} }

View file

@ -854,10 +854,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
@Override @Override
public void onGlobalLayout() { public void onGlobalLayout() {
LinearLayout container = ll.findViewById(R.id.app_modes_content); LinearLayout container = ll.findViewById(R.id.app_modes_content);
int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() int s = container.getChildAt(idx) != null ? container.getChildAt(idx).getRight() + rightTogglePadding : 0;
+ rightTogglePadding : 0; scrollView.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
scrollView
.scrollTo(s - scrollView.getWidth() > 0 ? s - scrollView.getWidth() : 0, 0);
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
ll.getViewTreeObserver().removeOnGlobalLayoutListener(this); ll.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else { } else {
@ -867,7 +865,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}; };
ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener); ll.getViewTreeObserver().addOnGlobalLayoutListener(globalListener);
} }
private void updateOptionsButtons() { private void updateOptionsButtons() {