Fix #3644
This commit is contained in:
parent
e9a0ff6e09
commit
e8d803a2eb
3 changed files with 20 additions and 14 deletions
|
@ -49,13 +49,15 @@ public class CurrentPositionHelper {
|
|||
this.app = app;
|
||||
}
|
||||
|
||||
public boolean getRouteSegment(Location loc, @Nullable ApplicationMode appMode,
|
||||
public boolean getRouteSegment(Location loc,
|
||||
@Nullable ApplicationMode appMode,
|
||||
boolean filterFrequentRequests,
|
||||
ResultMatcher<RouteDataObject> result) {
|
||||
return scheduleRouteSegmentFind(loc, false, true, null, result, appMode);
|
||||
return scheduleRouteSegmentFind(loc, false, true, filterFrequentRequests, null, result, appMode);
|
||||
}
|
||||
|
||||
|
||||
public boolean getGeocodingResult(Location loc, ResultMatcher<GeocodingResult> result) {
|
||||
return scheduleRouteSegmentFind(loc, false, false, result, null, null);
|
||||
return scheduleRouteSegmentFind(loc, false, false, true, result, null, null);
|
||||
}
|
||||
|
||||
public RouteDataObject getLastKnownRouteSegment(Location loc) {
|
||||
|
@ -68,12 +70,12 @@ public class CurrentPositionHelper {
|
|||
return r;
|
||||
}
|
||||
if (r == null) {
|
||||
scheduleRouteSegmentFind(loc, true, false, null, null, null);
|
||||
scheduleRouteSegmentFind(loc, true, false, true, null, null, null);
|
||||
return null;
|
||||
}
|
||||
double d = getOrthogonalDistance(r, loc);
|
||||
if (d > 15) {
|
||||
scheduleRouteSegmentFind(loc, true, false, null, null, null);
|
||||
scheduleRouteSegmentFind(loc, true, false, true, null, null, null);
|
||||
}
|
||||
if (d < 70) {
|
||||
return r;
|
||||
|
@ -90,6 +92,7 @@ public class CurrentPositionHelper {
|
|||
private boolean scheduleRouteSegmentFind(final Location loc,
|
||||
final boolean storeFound,
|
||||
final boolean allowEmptyNames,
|
||||
final boolean filterFrequentRequests,
|
||||
@Nullable final ResultMatcher<GeocodingResult> geoCoding,
|
||||
@Nullable final ResultMatcher<RouteDataObject> result,
|
||||
@Nullable final ApplicationMode appMode) {
|
||||
|
@ -106,7 +109,7 @@ public class CurrentPositionHelper {
|
|||
singleThreadExecutor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processGeocoding(loc, geoCoding, storeFound, allowEmptyNames, result, appMode, request, finalRequestNumber);
|
||||
processGeocoding(loc, geoCoding, storeFound, allowEmptyNames, result, appMode, request, finalRequestNumber, filterFrequentRequests);
|
||||
}
|
||||
});
|
||||
res = true;
|
||||
|
@ -155,9 +158,10 @@ public class CurrentPositionHelper {
|
|||
@Nullable final ResultMatcher<RouteDataObject> result,
|
||||
@Nullable ApplicationMode appMode,
|
||||
int request,
|
||||
@NonNull AtomicInteger requestNumber) {
|
||||
@NonNull AtomicInteger requestNumber,
|
||||
boolean filterFrequentRequests) {
|
||||
|
||||
if (request != requestNumber.get()) {
|
||||
if (filterFrequentRequests && request != requestNumber.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -854,10 +854,12 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
public RouteDataObject getLastKnownRouteSegment() {
|
||||
return currentPositionHelper.getLastKnownRouteSegment(getLastKnownLocation());
|
||||
}
|
||||
|
||||
public boolean getRouteSegment(net.osmand.Location loc, @Nullable ApplicationMode appMode,
|
||||
|
||||
public boolean getRouteSegment(net.osmand.Location loc,
|
||||
@Nullable ApplicationMode appMode,
|
||||
boolean filterFrequentRequests,
|
||||
ResultMatcher<RouteDataObject> result) {
|
||||
return currentPositionHelper.getRouteSegment(loc, appMode, result);
|
||||
return currentPositionHelper.getRouteSegment(loc, appMode, filterFrequentRequests, result);
|
||||
}
|
||||
|
||||
public boolean getGeocodingResult(net.osmand.Location loc, ResultMatcher<GeocodingResult> result) {
|
||||
|
|
|
@ -211,7 +211,7 @@ public class AvoidSpecificRoads {
|
|||
ll.setLongitude(loc.getLongitude());
|
||||
ApplicationMode appMode = app.getRoutingHelper().getAppMode();
|
||||
|
||||
app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher<RouteDataObject>() {
|
||||
app.getLocationProvider().getRouteSegment(ll, appMode, false, new ResultMatcher<RouteDataObject>() {
|
||||
|
||||
@Override
|
||||
public boolean publish(RouteDataObject object) {
|
||||
|
@ -246,7 +246,7 @@ public class AvoidSpecificRoads {
|
|||
ll.setLongitude(newLoc.getLongitude());
|
||||
ApplicationMode appMode = app.getRoutingHelper().getAppMode();
|
||||
|
||||
app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher<RouteDataObject>() {
|
||||
app.getLocationProvider().getRouteSegment(ll, appMode, false, new ResultMatcher<RouteDataObject>() {
|
||||
|
||||
@Override
|
||||
public boolean publish(RouteDataObject object) {
|
||||
|
|
Loading…
Reference in a new issue