create routingOptionsHelper variable

This commit is contained in:
Chumva 2019-03-07 12:04:01 +02:00
parent fd24868714
commit f0ba8d20dc

View file

@ -50,6 +50,8 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
private static final String AVOID_ROADS_TYPES_KEY = "avoid_roads_types"; private static final String AVOID_ROADS_TYPES_KEY = "avoid_roads_types";
private static final String AVOID_ROADS_OBJECTS_KEY = "avoid_roads_objects"; private static final String AVOID_ROADS_OBJECTS_KEY = "avoid_roads_objects";
private RoutingOptionsHelper routingOptionsHelper;
private HashMap<String, Boolean> routingParametersMap; private HashMap<String, Boolean> routingParametersMap;
private List<LatLon> removedImpassableRoads; private List<LatLon> removedImpassableRoads;
private LinearLayout stylesContainer; private LinearLayout stylesContainer;
@ -62,6 +64,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
if (app == null) { if (app == null) {
return; return;
} }
routingOptionsHelper = app.getRoutingOptionsHelper();
if (savedInstanceState != null) { if (savedInstanceState != null) {
if (savedInstanceState.containsKey(AVOID_ROADS_TYPES_KEY)) { if (savedInstanceState.containsKey(AVOID_ROADS_TYPES_KEY)) {
routingParametersMap = (HashMap<String, Boolean>) savedInstanceState.getSerializable(AVOID_ROADS_TYPES_KEY); routingParametersMap = (HashMap<String, Boolean>) savedInstanceState.getSerializable(AVOID_ROADS_TYPES_KEY);
@ -200,7 +203,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
for (Map.Entry<String, Boolean> entry : routingParametersMap.entrySet()) { for (Map.Entry<String, Boolean> entry : routingParametersMap.entrySet()) {
final String parameterId = entry.getKey(); final String parameterId = entry.getKey();
boolean selected = entry.getValue(); boolean selected = entry.getValue();
GeneralRouter.RoutingParameter parameter = app.getRoutingOptionsHelper().getRoutingPrefsForAppModeById(app.getRoutingHelper().getAppMode(), parameterId); GeneralRouter.RoutingParameter parameter = routingOptionsHelper.getRoutingPrefsForAppModeById(app.getRoutingHelper().getAppMode(), parameterId);
String defValue = ""; String defValue = "";
if (parameter != null) { if (parameter != null) {
defValue = parameter.getName(); defValue = parameter.getName();
@ -266,7 +269,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
for (Map.Entry<String, Boolean> entry : routingParametersMap.entrySet()) { for (Map.Entry<String, Boolean> entry : routingParametersMap.entrySet()) {
String parameterId = entry.getKey(); String parameterId = entry.getKey();
GeneralRouter.RoutingParameter parameter = app.getRoutingOptionsHelper().getRoutingPrefsForAppModeById(app.getRoutingHelper().getAppMode(), parameterId); GeneralRouter.RoutingParameter parameter = routingOptionsHelper.getRoutingPrefsForAppModeById(app.getRoutingHelper().getAppMode(), parameterId);
if (parameter != null) { if (parameter != null) {
boolean checked = entry.getValue(); boolean checked = entry.getValue();
OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean()); OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean());
@ -298,7 +301,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
@NonNull @NonNull
private HashMap<String, Boolean> generateStylesMap(OsmandApplication app) { private HashMap<String, Boolean> generateStylesMap(OsmandApplication app) {
HashMap<String, Boolean> res = new HashMap<>(); HashMap<String, Boolean> res = new HashMap<>();
List<GeneralRouter.RoutingParameter> avoidParameters = app.getRoutingOptionsHelper().getAvoidRoutingPrefsForAppMode(app.getRoutingHelper().getAppMode()); List<GeneralRouter.RoutingParameter> avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(app.getRoutingHelper().getAppMode());
for (GeneralRouter.RoutingParameter parameter : avoidParameters) { for (GeneralRouter.RoutingParameter parameter : avoidParameters) {
OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean()); OsmandSettings.CommonPreference<Boolean> preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean());