Fix possible npe
This commit is contained in:
parent
124cc6590f
commit
defff46e4c
2 changed files with 5 additions and 6 deletions
|
@ -664,9 +664,9 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
} else if (preference == defaultSpeed) {
|
} else if (preference == defaultSpeed) {
|
||||||
showSeekbarSettingsDialog(this, false);
|
showSeekbarSettingsDialog(this, false, settings.getApplicationMode());
|
||||||
} else if (preference == defaultSpeedOnly) {
|
} else if (preference == defaultSpeedOnly) {
|
||||||
showSeekbarSettingsDialog(this, true);
|
showSeekbarSettingsDialog(this, true, settings.getApplicationMode());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -720,14 +720,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
return bld.show();
|
return bld.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showSeekbarSettingsDialog(Activity activity, final boolean defaultSpeedOnly) {
|
public static void showSeekbarSettingsDialog(Activity activity, final boolean defaultSpeedOnly, final ApplicationMode mode) {
|
||||||
if (activity == null) {
|
if (activity == null || mode == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
|
|
||||||
final ApplicationMode mode = settings.getApplicationMode();
|
|
||||||
GeneralRouter router = getRouter(app.getRoutingConfig(), mode);
|
GeneralRouter router = getRouter(app.getRoutingConfig(), mode);
|
||||||
SpeedConstants units = settings.SPEED_SYSTEM.get();
|
SpeedConstants units = settings.SPEED_SYSTEM.get();
|
||||||
String speedUnits = units.toShortString(activity);
|
String speedUnits = units.toShortString(activity);
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
if (preference.getKey().equals(GeneralRouter.DEFAULT_SPEED)) {
|
if (preference.getKey().equals(GeneralRouter.DEFAULT_SPEED)) {
|
||||||
RouteService routeService = getSelectedAppMode().getRouteService();
|
RouteService routeService = getSelectedAppMode().getRouteService();
|
||||||
showSeekbarSettingsDialog(getActivity(), routeService == RouteService.STRAIGHT);
|
showSeekbarSettingsDialog(getActivity(), routeService == RouteService.STRAIGHT, getSelectedAppMode());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onPreferenceClick(preference);
|
return super.onPreferenceClick(preference);
|
||||||
|
|
Loading…
Reference in a new issue