From 1f4eef46cad17c79953313617a5de9c9ed957633 Mon Sep 17 00:00:00 2001 From: Denis_Bars Date: Sat, 2 Aug 2014 18:55:29 +0300 Subject: [PATCH] Fixed bug with waypoint being announced twice --- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index f4a1f8dab4..b6ee68c83d 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -105,7 +105,6 @@ public class OsmAndLocationProvider implements SensorEventListener { private static final int NOT_ANNOUNCED = 0; private static final int ANNOUNCED_ONCE = 1; - private static final int ANNOUNCED_TWICE = 2; private ConcurrentHashMap locationPointsStates = new ConcurrentHashMap(); private List visibleLocationPoints = new CopyOnWriteArrayList(); @@ -184,12 +183,12 @@ public class OsmAndLocationProvider implements SensorEventListener { double d1 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(), point.getLatitude(), point.getLongitude()); int state = locationPointsStates.get(point); - if (state == NOT_ANNOUNCED && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 500)){ + if(state <= ANNOUNCED_ONCE && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 150)) { + nameToAnnounce = (nameToAnnounce == null ? "" : ", ") + point.getName(); + locationPointsStates.remove(point); + } else if (state == NOT_ANNOUNCED && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 500)){ nameToAnnounce = (nameToAnnounce == null? "":", ")+point.getName(); locationPointsStates.put(point, state + 1); - } else if(state == ANNOUNCED_ONCE && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 150)){ - nameToAnnounce = (nameToAnnounce == null? "":", ")+point.getName(); - locationPointsStates.remove(point); } } if(nameToAnnounce!= null) {