From b394678c65193edf09d5717162f5db6d075e2b3b Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Tue, 9 Sep 2014 19:47:22 +0200 Subject: fix #4336: better auto increase of waypoint name --- main/src/cgeo/geocaching/EditWaypointActivity.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java index 5dfb1d5..2666cdd 100644 --- a/main/src/cgeo/geocaching/EditWaypointActivity.java +++ b/main/src/cgeo/geocaching/EditWaypointActivity.java @@ -328,12 +328,14 @@ public class EditWaypointActivity extends AbstractActionBarActivity implements C return type.getL10n(); } } - // for other types add an index by default - int index = 1; - while (wpNames.contains(type.getL10n() + " " + index)) { - index++; + // for other types add an index by default, which is highest found index + 1 + int max = 0; + for (int i = 0; i < 30; i++) { + if (wpNames.contains(type.getL10n() + " " + i)) { + max = i; + } } - return type.getL10n() + " " + index; + return type.getL10n() + " " + (max + 1); } private WaypointType getSelectedWaypointType() { -- cgit v1.1