refactoring

This commit is contained in:
madwasp79 2019-07-03 10:33:55 +03:00
parent a333533f49
commit 6aa48d1a94
2 changed files with 18 additions and 23 deletions

View file

@ -86,19 +86,17 @@ public class AppModeDialog {
int buttonWidth = AndroidUtils.dpToPx(a, (int) a.getResources().getDimension(R.dimen.route_info_modes_height));
List<ApplicationMode> modes = new ArrayList<>(ApplicationMode.values(app));
final HorizontalScrollView sv = ll.findViewById(R.id.app_modes_scroll_container);
if (app.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
for (int i = 0; i < modes.size(); i++) {
if (modes.get(i).equals(app.getSettings().getApplicationMode())
&& (i - 1) * buttonWidth > AndroidUtils.getScreenWidth(a)) {
final ApplicationMode activeMode = app.getSettings().getApplicationMode();
final boolean orientationPortrait = app.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
for (int i = 0; i < modes.size(); i++) {
if (modes.get(i).equals(activeMode)) {
if (orientationPortrait && i * buttonWidth > AndroidUtils.getScreenWidth(a)) {
scrollLength[0] = i * buttonWidth - AndroidUtils.getScreenWidth(a);
}
}
} else {
for (int i = 0; i < modes.size(); i++) {
if (modes.get(i).equals(app.getSettings().getApplicationMode())) {
} else if (!orientationPortrait &&
i * buttonWidth > app.getResources().getDimension(R.dimen.dashboard_land_width)){
scrollLength[0] = i * buttonWidth - (int) app.getResources()
.getDimension(R.dimen.dashboard_land_width);
.getDimension(R.dimen.dashboard_land_width);
}
}
}

View file

@ -841,19 +841,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
final int[] scrollLength = {0};
int buttonWidth = AndroidUtils.dpToPx(mapActivity,
(int) mapActivity.getResources().getDimension(R.dimen.route_info_modes_height));
if (app.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_PORTRAIT) {
for (int i = 0; i < values.size(); i++) {
if (values.get(i).equals(app.getSettings().getApplicationMode())
&& (i - 1) * buttonWidth > AndroidUtils.getScreenWidth(mapActivity)) {
int buttonWidth = AndroidUtils.dpToPx(mapActivity, (int) mapActivity.getResources().getDimension(R.dimen.route_info_modes_height));
final boolean orientationPortrait = app.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
final ApplicationMode activeMode = app.getSettings().getApplicationMode();
for (int i = 0; i < values.size(); i++) {
if (values.get(i).equals(activeMode)) {
if (orientationPortrait && i * buttonWidth > AndroidUtils.getScreenWidth(mapActivity)) {
scrollLength[0] = i * buttonWidth - AndroidUtils.getScreenWidth(mapActivity);
}
}
} else {
for (int i = 0; i < values.size(); i++) {
if (values.get(i).equals(app.getSettings().getApplicationMode())) {
} else if (!orientationPortrait &&
i * buttonWidth > app.getResources().getDimension(R.dimen.dashboard_land_width)){
scrollLength[0] = i * buttonWidth - (int) app.getResources()
.getDimension(R.dimen.dashboard_land_width);
}