From 50162f229ab53c555a52b57f41842fecf4ec7e71 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Thu, 17 Dec 2020 17:25:15 +0200 Subject: [PATCH] Sort: Allow to reverse all points --- .../plus/helpers/WaypointDialogHelper.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 628bc7ed71..24d684a408 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -39,6 +39,7 @@ import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -266,17 +267,13 @@ public class WaypointDialogHelper { public static void switchAllPoint(final OsmandApplication app, final Activity ctx, final WaypointDialogHelper helper) { - List all; TargetPointsHelper targets = app.getTargetPointsHelper(); - all = targets.getIntermediatePointsWithTarget(); - - List cur = targets.getIntermediatePointsWithTarget(); - for (int j = 0; j < cur.size() && j < all.size(); j++) { - if (cur.get(j) != all.get(j)) { - break; - } - } - targets.reorderAllTargetPoints(all, true); + List points = targets.getAllPoints(); + Collections.reverse(points); + TargetPoint start = points.get(0); + targets.setStartPoint(start.point, false, start.getOriginalPointDescription()); + points.remove(start); + targets.reorderAllTargetPoints(points, true); updateControls(ctx, helper); } @@ -508,8 +505,6 @@ public class WaypointDialogHelper { .create(); items.add(reorderStartAndFinishItem); - items.add(new DividerHalfItem(getContext())); - BaseBottomSheetItem reorderAllItems = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_sort_reverse_order)) .setTitle(getString(R.string.switch_all_points)) @@ -530,12 +525,14 @@ public class WaypointDialogHelper { }) .create(); if (getMyApplication() != null) { - int intermediateSize = getMyApplication().getTargetPointsHelper().getAllPoints().size(); + int intermediateSize = getMyApplication().getTargetPointsHelper().getIntermediatePoints().size(); if (intermediateSize > 2) { items.add(reorderAllItems); } } + items.add(new DividerHalfItem(getContext())); + final BaseBottomSheetItem[] addWaypointItem = new BaseBottomSheetItem[1]; addWaypointItem[0] = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_plus))