Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9fce28e159
3 changed files with 38 additions and 18 deletions
|
@ -2,13 +2,6 @@ package net.osmand.plus;
|
|||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
|
@ -17,13 +10,21 @@ import net.osmand.binary.GeocodingUtilities;
|
|||
import net.osmand.binary.GeocodingUtilities.GeocodingResult;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.plus.resources.RegionAddressRepository;
|
||||
import net.osmand.plus.resources.ResourceManager.ResourceListener;
|
||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||
import net.osmand.router.RoutePlannerFrontEnd;
|
||||
import net.osmand.router.RoutingConfiguration;
|
||||
import net.osmand.router.RoutingContext;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
public class CurrentPositionHelper {
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CurrentPositionHelper implements ResourceListener {
|
||||
|
||||
private RouteDataObject lastFound;
|
||||
private Location lastAskedLocation = null;
|
||||
|
@ -31,6 +32,7 @@ public class CurrentPositionHelper {
|
|||
private RoutingContext defCtx;
|
||||
private OsmandApplication app;
|
||||
private ApplicationMode am;
|
||||
private boolean mapsIndexed;
|
||||
|
||||
public CurrentPositionHelper(OsmandApplication app) {
|
||||
this.app = app;
|
||||
|
@ -216,12 +218,18 @@ public class CurrentPositionHelper {
|
|||
|
||||
|
||||
private synchronized List<GeocodingResult> runUpdateInThread(double lat, double lon, boolean geocoding) throws IOException {
|
||||
if (ctx == null || am != app.getSettings().getApplicationMode()) {
|
||||
if (ctx == null || mapsIndexed || am != app.getSettings().getApplicationMode()) {
|
||||
initCtx(app);
|
||||
mapsIndexed = false;
|
||||
if (ctx == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new GeocodingUtilities().reverseGeocodingSearch(geocoding ? defCtx : ctx, lat, lon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapsIndexed() {
|
||||
mapsIndexed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,6 +224,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
USE_MAGNETIC_FIELD_SENSOR_COMPASS = settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS;
|
||||
USE_FILTER_FOR_COMPASS = settings.USE_KALMAN_FILTER_FOR_COMPASS;
|
||||
currentPositionHelper = new CurrentPositionHelper(app);
|
||||
app.getResourceManager().addResourceListener(currentPositionHelper);
|
||||
locationSimulation = new OsmAndLocationSimulation(app, this);
|
||||
addLocationListener(navigationInfo);
|
||||
addCompassListener(navigationInfo);
|
||||
|
|
|
@ -95,15 +95,14 @@ public class ResourceManager {
|
|||
protected File dirWithTiles ;
|
||||
|
||||
private final OsmandApplication context;
|
||||
|
||||
public interface ResourceWatcher {
|
||||
|
||||
|
||||
public boolean indexResource(File f);
|
||||
|
||||
public List<String> getWatchWorkspaceFolder();
|
||||
|
||||
private List<ResourceListener> resourceListeners = new ArrayList<>();
|
||||
|
||||
public interface ResourceListener {
|
||||
|
||||
void onMapsIndexed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Indexes
|
||||
private final Map<String, RegionAddressRepository> addressMap = new ConcurrentHashMap<String, RegionAddressRepository>();
|
||||
|
@ -155,7 +154,16 @@ public class ResourceManager {
|
|||
return renderingBufferImageThread;
|
||||
}
|
||||
|
||||
|
||||
public void addResourceListener(ResourceListener listener) {
|
||||
if (!resourceListeners.contains(listener)) {
|
||||
resourceListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeResourceListener(ResourceListener listener) {
|
||||
resourceListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void resetStoreDirectory() {
|
||||
dirWithTiles = context.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||
dirWithTiles.mkdirs();
|
||||
|
@ -730,6 +738,9 @@ public class ResourceManager {
|
|||
log.error("Index file could not be written", e);
|
||||
}
|
||||
}
|
||||
for (ResourceListener l : resourceListeners) {
|
||||
l.onMapsIndexed();
|
||||
}
|
||||
return warnings;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue