Make getRouter not static

This commit is contained in:
Vitaliy 2020-02-17 15:17:54 +02:00
parent 2f3474766e
commit 052270132f
6 changed files with 12 additions and 12 deletions

View file

@ -844,12 +844,12 @@ public class OsmandApplication extends MultiDexApplication {
return builder != null ? builder : getDefaultRoutingConfig();
}
public static GeneralRouter getRouter(OsmandApplication app, ApplicationMode mode) {
Builder builder = app.getRoutingConfigForMode(mode);
public GeneralRouter getRouter(ApplicationMode mode) {
Builder builder = getRoutingConfigForMode(mode);
return getRouter(builder, mode);
}
public static GeneralRouter getRouter(Builder builder, ApplicationMode am) {
public GeneralRouter getRouter(Builder builder, ApplicationMode am) {
GeneralRouter router = builder.getRouter(am.getRoutingProfile());
if (router == null && am.getParent() != null) {
router = builder.getRouter(am.getParent().getStringKey());

View file

@ -314,7 +314,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
cat.addPreference(fastRoute);
} else {
ApplicationMode am = settings.getApplicationMode();
GeneralRouter router = OsmandApplication.getRouter(settings.getContext(), am);
GeneralRouter router = settings.getContext().getRouter(am);
clearParameters();
if (router != null) {
GeneralRouterProfile routerProfile = router.getProfile();
@ -719,7 +719,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final OsmandSettings settings = app.getSettings();
GeneralRouter router = OsmandApplication.getRouter(app, mode);
GeneralRouter router = app.getRouter(mode);
SpeedConstants units = settings.SPEED_SYSTEM.getModeValue(mode);
String speedUnits = units.toShortString(activity);
final float[] ratio = new float[1];

View file

@ -407,7 +407,7 @@ public class RoutingOptionsHelper {
public LocalRoutingParameter getRoutingParameterInnerById(ApplicationMode am, String parameterId) {
RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
GeneralRouter rm = OsmandApplication.getRouter(app, am);
GeneralRouter rm = app.getRouter(am);
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
return null;
}
@ -491,7 +491,7 @@ public class RoutingOptionsHelper {
RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
List<LocalRoutingParameter> list = new ArrayList<LocalRoutingParameter>(getGpxRouterParameters(am));
GeneralRouter rm = OsmandApplication.getRouter(app, am);
GeneralRouter rm = app.getRouter(am);
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
return list;
}
@ -581,7 +581,7 @@ public class RoutingOptionsHelper {
public List<GeneralRouter.RoutingParameter> getAvoidRoutingPrefsForAppMode(ApplicationMode applicationMode) {
List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
GeneralRouter router = OsmandApplication.getRouter(app, applicationMode);
GeneralRouter router = app.getRouter(applicationMode);
if (router != null) {
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : router.getParameters().entrySet()) {
String param = e.getKey();
@ -595,7 +595,7 @@ public class RoutingOptionsHelper {
}
public GeneralRouter.RoutingParameter getRoutingPrefsForAppModeById(ApplicationMode applicationMode, String parameterId) {
GeneralRouter router = OsmandApplication.getRouter(app, applicationMode);
GeneralRouter router = app.getRouter(applicationMode);
GeneralRouter.RoutingParameter parameter = null;
if (router != null) {

View file

@ -600,7 +600,7 @@ public class RouteProvider {
router.setUseFastRecalculation(settings.USE_FAST_RECALCULATION.get());
RoutingConfiguration.Builder config = params.ctx.getRoutingConfigForMode(params.mode);
GeneralRouter generalRouter = OsmandApplication.getRouter(config, params.mode);
GeneralRouter generalRouter = params.ctx.getRouter(config, params.mode);
if (generalRouter == null) {
return applicationModeNotSupported(params);
}

View file

@ -139,7 +139,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
if (am.getRouteService() != RouteProvider.RouteService.OSMAND) {
screen.addPreference(fastRoute);
} else {
GeneralRouter router = OsmandApplication.getRouter(app, am);
GeneralRouter router = app.getRouter(am);
clearParameters();
if (router != null) {
Map<String, RoutingParameter> parameters = router.getParameters();

View file

@ -41,7 +41,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
RouteService routeService = mode.getRouteService();
if (routeService == RouteService.OSMAND) {
GeneralRouter router = OsmandApplication.getRouter(app, mode);
GeneralRouter router = app.getRouter(mode);
if (router != null) {
Map<String, GeneralRouter.RoutingParameter> parameters = router.getParameters();