Simplify layer structure make poi/favorites layers all the time present
This commit is contained in:
parent
f52c305403
commit
33eb95caaa
10 changed files with 75 additions and 89 deletions
|
@ -747,9 +747,6 @@ public class OsmandSettings {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
|
||||||
public final OsmandPreference<Boolean> SHOW_POI_OVER_MAP = new BooleanPreference("show_poi_over_map", false).makeGlobal();
|
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal();
|
public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
@ -925,7 +922,7 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Boolean> DEBUG_RENDERING_INFO = new BooleanPreference("debug_rendering", false).makeGlobal();
|
public final OsmandPreference<Boolean> DEBUG_RENDERING_INFO = new BooleanPreference("debug_rendering", false).makeGlobal();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<Boolean> SHOW_FAVORITES = new BooleanPreference("show_favorites", false).makeGlobal();
|
public final OsmandPreference<Boolean> SHOW_FAVORITES = new BooleanPreference("show_favorites", false).makeGlobal().cache();
|
||||||
|
|
||||||
public final CommonPreference<Boolean> SHOW_ZOOM_BUTTONS_NAVIGATION = new BooleanPreference("show_zoom_buttons_navigation", false).makeProfile().cache();
|
public final CommonPreference<Boolean> SHOW_ZOOM_BUTTONS_NAVIGATION = new BooleanPreference("show_zoom_buttons_navigation", false).makeProfile().cache();
|
||||||
{
|
{
|
||||||
|
@ -1672,15 +1669,8 @@ public class OsmandSettings {
|
||||||
return settingsAPI.edit(globalPreferences).putString(LAST_SEARCHED_INTERSECTED_STREET, street).commit();
|
return settingsAPI.edit(globalPreferences).putString(LAST_SEARCHED_INTERSECTED_STREET, street).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String SELECTED_POI_FILTER_FOR_MAP = "selected_poi_filter_for_map"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
public boolean setPoiFilterForMap(String filterId) {
|
public final OsmandPreference<String> SELECTED_POI_FILTER_FOR_MAP = new StringPreference("selected_poi_filter_for_map", null).makeGlobal().cache();
|
||||||
return settingsAPI.edit(globalPreferences).putString(SELECTED_POI_FILTER_FOR_MAP, filterId).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPoiFilterForMap(){
|
|
||||||
return settingsAPI.getString(globalPreferences,SELECTED_POI_FILTER_FOR_MAP, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String VOICE_PROVIDER_NOT_USE = "VOICE_PROVIDER_NOT_USE";
|
public static final String VOICE_PROVIDER_NOT_USE = "VOICE_PROVIDER_NOT_USE";
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
|
|
@ -368,9 +368,6 @@ public class MapActivity extends AccessibleActivity {
|
||||||
settings.APPLICATION_MODE.addListener(applicationModeListener);
|
settings.APPLICATION_MODE.addListener(applicationModeListener);
|
||||||
updateApplicationModeSettings();
|
updateApplicationModeSettings();
|
||||||
|
|
||||||
String filterId = settings.getPoiFilterForMap();
|
|
||||||
PoiLegacyFilter poiFilter = app.getPoiFilters().getFilterById(filterId);
|
|
||||||
mapLayers.getPoiMapLayer().setFilter(poiFilter);
|
|
||||||
|
|
||||||
// if destination point was changed try to recalculate route
|
// if destination point was changed try to recalculate route
|
||||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||||
|
|
|
@ -124,8 +124,10 @@ public class MapActivityLayers {
|
||||||
// 2. osm bugs layer
|
// 2. osm bugs layer
|
||||||
// 3. poi layer
|
// 3. poi layer
|
||||||
poiMapLayer = new POIMapLayer(activity);
|
poiMapLayer = new POIMapLayer(activity);
|
||||||
|
mapView.addLayer(poiMapLayer, 3);
|
||||||
// 4. favorites layer
|
// 4. favorites layer
|
||||||
favoritesLayer = new FavoritesLayer();
|
favoritesLayer = new FavoritesLayer();
|
||||||
|
mapView.addLayer(favoritesLayer, 4);
|
||||||
// 5. transport layer
|
// 5. transport layer
|
||||||
transportStopsLayer = new TransportStopsLayer();
|
transportStopsLayer = new TransportStopsLayer();
|
||||||
// 5.5 transport info layer
|
// 5.5 transport info layer
|
||||||
|
@ -173,22 +175,6 @@ public class MapActivityLayers {
|
||||||
mapView.removeLayer(transportStopsLayer);
|
mapView.removeLayer(transportStopsLayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mapView.getLayers().contains(poiMapLayer) != settings.SHOW_POI_OVER_MAP.get()){
|
|
||||||
if(settings.SHOW_POI_OVER_MAP.get()){
|
|
||||||
mapView.addLayer(poiMapLayer, 3);
|
|
||||||
} else {
|
|
||||||
mapView.removeLayer(poiMapLayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mapView.getLayers().contains(favoritesLayer) != settings.SHOW_FAVORITES.get()){
|
|
||||||
if(settings.SHOW_FAVORITES.get()){
|
|
||||||
mapView.addLayer(favoritesLayer, 4);
|
|
||||||
} else {
|
|
||||||
mapView.removeLayer(favoritesLayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OsmandPlugin.refreshLayers(mapView, activity);
|
OsmandPlugin.refreshLayers(mapView, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,12 +269,11 @@ public class MapActivityLayers {
|
||||||
activity.getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX);
|
activity.getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX);
|
||||||
activity.startActivity(search);
|
activity.startActivity(search);
|
||||||
} else {
|
} else {
|
||||||
getApplication().getSettings().setPoiFilterForMap(filterId);
|
|
||||||
pf = poiFilters.getFilterById(filterId);
|
pf = poiFilters.getFilterById(filterId);
|
||||||
if (pf != null) {
|
if (pf != null) {
|
||||||
pf.setFilterByName(pf.getSavedFilterByName());
|
pf.setFilterByName(pf.getSavedFilterByName());
|
||||||
}
|
}
|
||||||
poiMapLayer.setFilter(pf);
|
getApplication().getSettings().SELECTED_POI_FILTER_FOR_MAP.set(filterId);
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
if(selected != null && selected.length > 0) {
|
if(selected != null && selected.length > 0) {
|
||||||
selected[0] = pf;
|
selected[0] = pf;
|
||||||
|
|
|
@ -162,8 +162,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
OsmandSettings settings = app.getSettings();
|
OsmandSettings settings = app.getSettings();
|
||||||
filter.setFilterByName(searchFilter.getText().toString().trim());
|
filter.setFilterByName(searchFilter.getText().toString().trim());
|
||||||
settings.setPoiFilterForMap(filter.getFilterId());
|
settings.SELECTED_POI_FILTER_FOR_MAP.set(filter.getFilterId());
|
||||||
settings.SHOW_POI_OVER_MAP.set(true);
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), 15);
|
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), 15);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class ConfigureMapMenu {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onRowItemClick(ArrayAdapter<?> adapter, View view, int itemId, int pos) {
|
public boolean onRowItemClick(ArrayAdapter<?> adapter, View view, int itemId, int pos) {
|
||||||
if(itemId == R.string.layer_poi && cm.getSelection(pos) == 1) {
|
if(itemId == R.string.layer_poi) {
|
||||||
selectPOILayer(ma.getMyApplication().getSettings());
|
selectPOILayer(ma.getMyApplication().getSettings());
|
||||||
return false;
|
return false;
|
||||||
} else if(itemId == R.string.layer_gpx_layer && cm.getSelection(pos) == 1) {
|
} else if(itemId == R.string.layer_gpx_layer && cm.getSelection(pos) == 1) {
|
||||||
|
@ -107,13 +107,10 @@ public class ConfigureMapMenu {
|
||||||
public boolean onContextMenuClick(final ArrayAdapter<?> adapter, int itemId, final int pos, boolean isChecked) {
|
public boolean onContextMenuClick(final ArrayAdapter<?> adapter, int itemId, final int pos, boolean isChecked) {
|
||||||
final OsmandSettings settings = ma.getMyApplication().getSettings();
|
final OsmandSettings settings = ma.getMyApplication().getSettings();
|
||||||
if (itemId == R.string.layer_poi) {
|
if (itemId == R.string.layer_poi) {
|
||||||
settings.setPoiFilterForMap(null);
|
settings.SELECTED_POI_FILTER_FOR_MAP.set(null);
|
||||||
ma.getMapLayers().getPoiMapLayer().setFilter(null);
|
|
||||||
settings.SHOW_POI_OVER_MAP.set(isChecked);
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
selectPOILayer(settings);
|
selectPOILayer(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (itemId == R.string.layer_amenity_label) {
|
} else if (itemId == R.string.layer_amenity_label) {
|
||||||
settings.SHOW_POI_LABEL.set(isChecked);
|
settings.SHOW_POI_LABEL.set(isChecked);
|
||||||
} else if (itemId == R.string.shared_string_favorites) {
|
} else if (itemId == R.string.shared_string_favorites) {
|
||||||
|
@ -146,9 +143,6 @@ public class ConfigureMapMenu {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
if(selected[0] == null) {
|
|
||||||
settings.SHOW_POI_OVER_MAP.set(selected[0] != null);
|
|
||||||
}
|
|
||||||
ma.getDashboard().refreshContent(true);
|
ma.getDashboard().refreshContent(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -161,7 +155,7 @@ public class ConfigureMapMenu {
|
||||||
LayerMenuListener l = new LayerMenuListener(activity, adapter);
|
LayerMenuListener l = new LayerMenuListener(activity, adapter);
|
||||||
adapter.item(R.string.shared_string_show).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
adapter.item(R.string.shared_string_show).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||||
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
|
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
|
||||||
adapter.item(R.string.layer_poi).selected(settings.SHOW_POI_OVER_MAP.get() ? 1 : 0)
|
adapter.item(R.string.layer_poi).selected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null ? 1 : 0)
|
||||||
.iconColor(R.drawable.ic_action_info_dark).listen(l).reg();
|
.iconColor(R.drawable.ic_action_info_dark).listen(l).reg();
|
||||||
adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0)
|
adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0)
|
||||||
.iconColor(R.drawable.ic_action_text_dark).listen(l).reg();
|
.iconColor(R.drawable.ic_action_text_dark).listen(l).reg();
|
||||||
|
|
|
@ -238,7 +238,7 @@ public class WaypointDialogHelper {
|
||||||
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||||
final boolean enable, Activity ctx) {
|
final boolean enable, Activity ctx) {
|
||||||
if (ctx instanceof MapActivity &&
|
if (ctx instanceof MapActivity &&
|
||||||
!PoiLegacyFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
!PoiLegacyFilter.CUSTOM_FILTER_ID.equals(app.getSettings().SELECTED_POI_FILTER_FOR_MAP.get())) {
|
||||||
MapActivity map = (MapActivity) ctx;
|
MapActivity map = (MapActivity) ctx;
|
||||||
final PoiLegacyFilter[] selected = new PoiLegacyFilter[1];
|
final PoiLegacyFilter[] selected = new PoiLegacyFilter[1];
|
||||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||||
|
|
|
@ -592,7 +592,7 @@ public class WaypointHelper {
|
||||||
|
|
||||||
///
|
///
|
||||||
public PoiLegacyFilter getPoiFilter() {
|
public PoiLegacyFilter getPoiFilter() {
|
||||||
return app.getPoiFilters().getFilterById(app.getSettings().getPoiFilterForMap());
|
return app.getPoiFilters().getFilterById(app.getSettings().SELECTED_POI_FILTER_FOR_MAP.get());
|
||||||
}
|
}
|
||||||
public boolean showPOI() {
|
public boolean showPOI() {
|
||||||
return app.getSettings().SHOW_NEARBY_POI.get();
|
return app.getSettings().SHOW_NEARBY_POI.get();
|
||||||
|
|
|
@ -531,14 +531,14 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
||||||
R.string.menu_mute_on, R.string.menu_mute_off,
|
R.string.menu_mute_on, R.string.menu_mute_off,
|
||||||
R.string.where_am_i, R.string.context_menu_item_share_location);
|
R.string.where_am_i, R.string.context_menu_item_share_location);
|
||||||
//poi
|
//poi
|
||||||
if (osmandSettings.SHOW_POI_OVER_MAP.get()) {
|
if (osmandSettings.SELECTED_POI_FILTER_FOR_MAP.get()!= null) {
|
||||||
adapter.item(R.string.sherpafy_disable_poi).iconColor(
|
adapter.item(R.string.sherpafy_disable_poi).iconColor(
|
||||||
R.drawable.ic_action_gremove_dark)
|
R.drawable.ic_action_gremove_dark)
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
app.getSettings().SHOW_POI_OVER_MAP.set(false);
|
app.getSettings().SELECTED_POI_FILTER_FOR_MAP.set(null);
|
||||||
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
|
mapActivity.refreshMap();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).reg();
|
||||||
|
@ -548,8 +548,6 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
mapActivity.getMapLayers().selectPOIFilterLayer(mapActivity.getMapView(), null);
|
mapActivity.getMapLayers().selectPOIFilterLayer(mapActivity.getMapView(), null);
|
||||||
app.getSettings().SHOW_POI_OVER_MAP.set(true);
|
|
||||||
mapActivity.getMapLayers().updateLayers(mapActivity.getMapView());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).reg();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.FavoritesTreeFragment;
|
import net.osmand.plus.activities.FavoritesTreeFragment;
|
||||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||||
|
@ -39,6 +40,8 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
private FavouritesDbHelper favorites;
|
private FavouritesDbHelper favorites;
|
||||||
protected List<LocationPoint> cache = new ArrayList<LocationPoint>();
|
protected List<LocationPoint> cache = new ArrayList<LocationPoint>();
|
||||||
private MapTextLayer textLayer;
|
private MapTextLayer textLayer;
|
||||||
|
|
||||||
|
private OsmandSettings settings;
|
||||||
// private Bitmap d;
|
// private Bitmap d;
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setFilterBitmap(true);
|
paint.setFilterBitmap(true);
|
||||||
paint.setDither(true);
|
paint.setDither(true);
|
||||||
|
settings = view.getApplication().getSettings();
|
||||||
favorites = view.getApplication().getFavorites();
|
favorites = view.getApplication().getFavorites();
|
||||||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||||
// favoriteIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.poi_favourite);
|
// favoriteIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.poi_favourite);
|
||||||
|
@ -93,6 +96,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
cache.clear();
|
cache.clear();
|
||||||
|
if (this.settings.SHOW_FAVORITES.get()) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
// request to load
|
// request to load
|
||||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||||
|
@ -101,9 +105,11 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(textLayer.isVisible()) {
|
if(textLayer.isVisible()) {
|
||||||
textLayer.putData(this, cache);
|
textLayer.putData(this, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,18 @@ import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||||
import net.osmand.plus.render.RenderingIcons;
|
import net.osmand.plus.render.RenderingIcons;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -59,10 +63,16 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
// Work with cache (for map copied from AmenityIndexRepositoryOdb)
|
// Work with cache (for map copied from AmenityIndexRepositoryOdb)
|
||||||
private MapLayerData<List<Amenity>> data;
|
private MapLayerData<List<Amenity>> data;
|
||||||
|
|
||||||
|
private OsmandSettings settings;
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
|
||||||
|
|
||||||
public POIMapLayer(final MapActivity activity) {
|
public POIMapLayer(final MapActivity activity) {
|
||||||
routingHelper = activity.getRoutingHelper();
|
routingHelper = activity.getRoutingHelper();
|
||||||
routingHelper.addListener(this);
|
routingHelper.addListener(this);
|
||||||
|
settings = activity.getMyApplication().getSettings();
|
||||||
|
app = activity.getMyApplication();
|
||||||
data = new OsmandMapLayer.MapLayerData<List<Amenity>>() {
|
data = new OsmandMapLayer.MapLayerData<List<Amenity>>() {
|
||||||
{
|
{
|
||||||
ZOOM_THRESHOLD = 0;
|
ZOOM_THRESHOLD = 0;
|
||||||
|
@ -101,10 +111,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilter(PoiLegacyFilter filter) {
|
|
||||||
this.filter = filter;
|
|
||||||
data.clearCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getAmenityFromPoint(RotatedTileBox tb, PointF point, List<? super Amenity> am) {
|
public void getAmenityFromPoint(RotatedTileBox tb, PointF point, List<? super Amenity> am) {
|
||||||
List<Amenity> objects = data.getResults();
|
List<Amenity> objects = data.getResults();
|
||||||
|
@ -193,7 +199,18 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
|
if(!Algorithms.objectEquals(this.settings.SELECTED_POI_FILTER_FOR_MAP.get(),
|
||||||
|
filter == null ? null : filter.getFilterId())) {
|
||||||
|
if(this.settings.SELECTED_POI_FILTER_FOR_MAP.get() == null) {
|
||||||
|
this.filter = null;
|
||||||
|
} else {
|
||||||
|
PoiFiltersHelper pfh = app.getPoiFilters();
|
||||||
|
this.filter = pfh.getFilterById(this.settings.SELECTED_POI_FILTER_FOR_MAP.get());
|
||||||
|
}
|
||||||
|
data.clearCache();
|
||||||
|
}
|
||||||
List<Amenity> objects = Collections.emptyList();
|
List<Amenity> objects = Collections.emptyList();
|
||||||
|
if (filter != null) {
|
||||||
if (tileBox.getZoom() >= startZoom) {
|
if (tileBox.getZoom() >= startZoom) {
|
||||||
data.queryNewData(tileBox);
|
data.queryNewData(tileBox);
|
||||||
objects = data.getResults();
|
objects = data.getResults();
|
||||||
|
@ -224,8 +241,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mapTextLayer.putData(this, objects);
|
mapTextLayer.putData(this, objects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue