Use constant instead of hardcode

This commit is contained in:
Alex Sytnyk 2018-10-25 11:31:05 +03:00
parent 180a26077f
commit 3eb6f10a5d
6 changed files with 9 additions and 6 deletions

View file

@ -859,14 +859,14 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId)); getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId));
return; return;
} }
int color = -1; int color = TopToolbarController.NO_COLOR;
boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE; boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
boolean night = app.getDaynightHelper().isNightModeForMapControls(); boolean night = app.getDaynightHelper().isNightModeForMapControls();
TopToolbarController toolbarController = getMapLayers().getMapInfoLayer().getTopToolbarController(); TopToolbarController toolbarController = getMapLayers().getMapInfoLayer().getTopToolbarController();
if (toolbarController != null && mapControlsVisible) { if (toolbarController != null && mapControlsVisible) {
color = toolbarController.getStatusBarColor(this, night); color = toolbarController.getStatusBarColor(this, night);
} }
if (color == -1) { if (color == TopToolbarController.NO_COLOR) {
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE; boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE; boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
if (mapTopBar && mapControlsVisible) { if (mapTopBar && mapControlsVisible) {

View file

@ -333,7 +333,7 @@ public class DiscountHelper {
public static class DiscountBarController extends TopToolbarController { public static class DiscountBarController extends TopToolbarController {
private int statusBarColor = -1; private int statusBarColor = NO_COLOR;
DiscountBarController() { DiscountBarController() {
super(TopToolbarControllerType.DISCOUNT); super(TopToolbarControllerType.DISCOUNT);

View file

@ -634,7 +634,7 @@ public class TrackDetailsMenu {
@Override @Override
public int getStatusBarColor(Context context, boolean night) { public int getStatusBarColor(Context context, boolean night) {
return -1; return NO_COLOR;
} }
} }

View file

@ -969,7 +969,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
@Override @Override
public int getStatusBarColor(Context context, boolean night) { public int getStatusBarColor(Context context, boolean night) {
return -1; return NO_COLOR;
} }
} }
} }

View file

@ -1583,7 +1583,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
@Override @Override
public int getStatusBarColor(Context context, boolean night) { public int getStatusBarColor(Context context, boolean night) {
return -1; return NO_COLOR;
} }
} }
} }

View file

@ -218,6 +218,9 @@ public class MapInfoWidgetsFactory {
} }
public static class TopToolbarController { public static class TopToolbarController {
public static final int NO_COLOR = -1;
private TopToolbarControllerType type; private TopToolbarControllerType type;
@ColorRes @ColorRes