refactoring
This commit is contained in:
parent
a333533f49
commit
6aa48d1a94
2 changed files with 18 additions and 23 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue