Fix possible IndexOutOfBoundsException
This commit is contained in:
parent
30eac3412f
commit
26805c4ae8
6 changed files with 17 additions and 15 deletions
|
@ -11,6 +11,7 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="gpx_parse_error">OsmAnd GPX is not well formed, please contact support team to investigate further</string>
|
||||
<string name="unsupported_type_error">Unsupported type</string>
|
||||
<string name="index_item_world_basemap_detailed">World overview map (detailed)</string>
|
||||
<string name="profiles_for_action_not_found">Could not find any such profiles.</string>
|
||||
|
|
|
@ -79,7 +79,7 @@ public class OsmAndLocationSimulation {
|
|||
@Override
|
||||
public boolean processResult(GPXUtilities.GPXFile[] result) {
|
||||
GPXRouteParamsBuilder builder = new GPXRouteParamsBuilder(result[0], app.getSettings());
|
||||
startAnimationThread(app, builder.getPoints(), true, speedup.getValue() + 1);
|
||||
startAnimationThread(app, builder.getPoints(app), true, speedup.getValue() + 1);
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
}
|
||||
|
|
|
@ -514,7 +514,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
params.setCalculateOsmAndRouteParts(settings.GPX_ROUTE_CALC_OSMAND_PARTS.get());
|
||||
params.setUseIntermediatePointsRTE(settings.GPX_CALCULATE_RTEPT.get());
|
||||
params.setCalculateOsmAndRoute(settings.GPX_ROUTE_CALC.get());
|
||||
List<Location> ps = params.getPoints();
|
||||
List<Location> ps = params.getPoints(settings.getContext());
|
||||
mapActivity.getRoutingHelper().setGpxParams(params);
|
||||
settings.FOLLOW_THE_GPX_ROUTE.set(result.path);
|
||||
if (!ps.isEmpty()) {
|
||||
|
|
|
@ -237,7 +237,7 @@ public class RoutingOptionsHelper {
|
|||
if (gpxParam.id == R.string.gpx_option_reverse_route) {
|
||||
rp.setReverse(selected);
|
||||
TargetPointsHelper tg = app.getTargetPointsHelper();
|
||||
List<Location> ps = rp.getPoints();
|
||||
List<Location> ps = rp.getPoints(app);
|
||||
if (ps.size() > 0) {
|
||||
Location first = ps.get(0);
|
||||
Location end = ps.get(ps.size() - 1);
|
||||
|
|
|
@ -19,15 +19,15 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.osm.io.NetworkUtils;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
import net.osmand.router.GeneralRouter.RoutingParameter;
|
||||
import net.osmand.router.GeneralRouter.RoutingParameterType;
|
||||
|
@ -173,12 +173,14 @@ public class RouteProvider {
|
|||
return passWholeRoute;
|
||||
}
|
||||
|
||||
public GPXRouteParams build(Location start, OsmandSettings settings) {
|
||||
public GPXRouteParams build(OsmandApplication app) {
|
||||
GPXRouteParams res = new GPXRouteParams();
|
||||
res.prepareGPXFile(this);
|
||||
// if (passWholeRoute && start != null) {
|
||||
// res.points.add(0, start);
|
||||
// }
|
||||
try {
|
||||
res.prepareGPXFile(this);
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
app.showShortToastMessage(app.getString(R.string.gpx_parse_error));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -190,9 +192,8 @@ public class RouteProvider {
|
|||
return file;
|
||||
}
|
||||
|
||||
public List<Location> getPoints() {
|
||||
GPXRouteParams copy = new GPXRouteParams();
|
||||
copy.prepareGPXFile(this);
|
||||
public List<Location> getPoints(OsmandApplication app) {
|
||||
GPXRouteParams copy = build(app);
|
||||
return copy.getPoints();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1172,7 +1172,7 @@ public class RoutingHelper {
|
|||
params.start = start;
|
||||
params.end = end;
|
||||
params.intermediates = intermediates;
|
||||
params.gpxRoute = gpxRoute == null ? null : gpxRoute.build(start, settings);
|
||||
params.gpxRoute = gpxRoute == null ? null : gpxRoute.build(app);
|
||||
params.onlyStartPointChanged = onlyStartPointChanged;
|
||||
if (recalculateCountInInterval < RECALCULATE_THRESHOLD_COUNT_CAUSING_FULL_RECALCULATE
|
||||
|| (gpxRoute != null && gpxRoute.isPassWholeRoute() && isDeviatedFromRoute)) {
|
||||
|
|
Loading…
Reference in a new issue