Finally fixed issue 875
This commit is contained in:
parent
b0a85d36c3
commit
f116748bff
6 changed files with 49 additions and 3 deletions
|
@ -28,4 +28,8 @@ public interface AmenityIndexRepository {
|
|||
public void evaluateCachedAmenities(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom,
|
||||
PoiFilter filter, ResultMatcher<Amenity> matcher);
|
||||
|
||||
public boolean hasChange();
|
||||
|
||||
public void clearChange();
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,16 @@ public class AmenityIndexRepositoryBinary implements AmenityIndexRepository {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasChange() {
|
||||
return false; //no change ever
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearChange() {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkContains(double latitude, double longitude) {
|
||||
return index.containsPoiData(latitude, longitude);
|
||||
|
|
|
@ -43,6 +43,8 @@ public class AmenityIndexRepositoryOdb extends BaseLocationIndexRepository<Ameni
|
|||
|
||||
|
||||
private final String[] columns = new String[]{"id", "x", "y", "name", "name_en", "type", "subtype", "opening_hours", "phone", "site"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$//$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
|
||||
private boolean changes = false;
|
||||
|
||||
@Override
|
||||
public List<Amenity> searchAmenities(int stop, int sleft, int sbottom, int sright, int zoom, PoiFilter filter,
|
||||
List<Amenity> amenities, ResultMatcher<Amenity> matcher){
|
||||
|
@ -177,11 +179,14 @@ public class AmenityIndexRepositoryOdb extends BaseLocationIndexRepository<Ameni
|
|||
new Object[] { MapUtils.get31TileNumberX(a.getLocation().getLongitude()), MapUtils.get31TileNumberY(a.getLocation().getLatitude()),
|
||||
a.getOpeningHours(), a.getName(), a.getEnName(), AmenityType.valueToString(a.getType()), a.getSubType(),
|
||||
a.getSite(), a.getPhone(), a.getId()});
|
||||
|
||||
changes = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean deleteAmenities(long id){
|
||||
db.execSQL("DELETE FROM " + IndexConstants.POI_TABLE+ " WHERE id="+id); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
changes = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -227,7 +232,17 @@ public class AmenityIndexRepositoryOdb extends BaseLocationIndexRepository<Ameni
|
|||
}
|
||||
stat.close();
|
||||
updateMaxMinBoundaries(IndexConstants.POI_TABLE);
|
||||
changes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChange() {
|
||||
return changes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearChange() {
|
||||
changes = false;
|
||||
}
|
||||
|
||||
private final static String SITE_API = "http://api.openstreetmap.org/"; //$NON-NLS-1$
|
||||
|
|
|
@ -267,8 +267,17 @@ public class AsyncLoadingThread extends Thread {
|
|||
};
|
||||
}
|
||||
|
||||
private boolean repoHasChange() {
|
||||
for (AmenityIndexRepository r : res) {
|
||||
if (r.hasChange()) {
|
||||
r.clearChange();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean recalculateRequest(AmenityLoadRequest req) {
|
||||
if (this.zoom != req.zoom || !Algoritms.objectEquals(this.filter, req.filter)) {
|
||||
if (this.zoom != req.zoom || !Algoritms.objectEquals(this.filter, req.filter) || req.repoHasChange()) {
|
||||
return true;
|
||||
}
|
||||
return !isContains(req.topLatitude, req.leftLongitude, req.bottomLatitude, req.rightLongitude);
|
||||
|
|
|
@ -105,6 +105,14 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
|
|
|
@ -173,7 +173,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
@Override
|
||||
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
||||
|
||||
if (view.getZoom() >= startZoom || nightMode.isForce()) {
|
||||
if (view.getZoom() >= startZoom) {
|
||||
objects.clear();
|
||||
resourceManager.searchAmenitiesAsync(latLonBounds.top, latLonBounds.left, latLonBounds.bottom, latLonBounds.right, view.getZoom(), filter, objects);
|
||||
int r = getRadiusPoi(view.getZoom());
|
||||
|
|
Loading…
Reference in a new issue