Show toast when trying to switch start/finish and finish empty

This commit is contained in:
crimean 2019-02-18 17:23:34 +03:00
parent a3aa837ff5
commit fdad323ab0
3 changed files with 31 additions and 24 deletions

View file

@ -10,6 +10,7 @@
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
Thx - Hardy
-->
<string name="add_destination_query">Please add Destination first</string>
<string name="previous_route">Previous route</string>
<string name="add_home">Add home</string>
<string name="add_work">Add work</string>

View file

@ -242,6 +242,9 @@ public class WaypointDialogHelper {
public static void switchStartAndFinish(TargetPointsHelper targetPointsHelper, TargetPoint finish,
Activity ctx, TargetPoint start, OsmandApplication app,
WaypointDialogHelper helper) {
if (finish == null) {
app.showShortToastMessage(R.string.add_destination_query);
} else {
targetPointsHelper.setStartPoint(new LatLon(finish.getLatitude(),
finish.getLongitude()), false, finish.getPointDescription(ctx));
if (start == null) {
@ -256,6 +259,7 @@ public class WaypointDialogHelper {
}
updateControls(ctx, helper);
}
}
public static void updateControls(Activity ctx, WaypointDialogHelper helper) {
if (helper != null && helper.helperCallbacks != null) {

View file

@ -1049,7 +1049,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
TargetPointsHelper targetPointsHelper = getTargets();
TargetPoint startPoint = targetPointsHelper.getPointToStart();
TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
if (endPoint == null) {
app.showShortToastMessage(R.string.add_destination_query);
} else {
if (startPoint == null) {
Location loc = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
if (loc != null) {
@ -1058,13 +1060,13 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
mapActivity.getString(R.string.shared_string_my_location)));
}
}
if (startPoint != null && endPoint != null) {
if (startPoint != null) {
targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
targetPointsHelper.updateRouteAndRefresh(true);
}
}
}
});
updateFromIcon(mainView);