wikipedia poi fixes

This commit is contained in:
Nazar-Kutz 2020-06-01 17:25:22 +03:00
parent 05eb4d701c
commit c1228dc82f
4 changed files with 8 additions and 21 deletions

View file

@ -58,7 +58,6 @@ public class PoiFiltersHelper {
private PoiUIFilter topWikiPoiFilter;
private List<PoiUIFilter> cacheTopStandardFilters;
private Set<PoiUIFilter> selectedPoiFilters = new TreeSet<>();
private boolean updatePoiFiltersOnMap;
private static final String UDF_CAR_AID = "car_aid";
private static final String UDF_FOR_TOURISTS = "for_tourists";
@ -487,7 +486,7 @@ public class PoiFiltersHelper {
}
public Set<PoiUIFilter> getSelectedPoiFilters(PoiUIFilter ... filtersToExclude) {
if (filtersToExclude != null) {
if (filtersToExclude != null && filtersToExclude.length > 0) {
Set<PoiUIFilter> filters = new TreeSet<>();
for (PoiUIFilter filter : selectedPoiFilters) {
boolean skip = false;
@ -592,7 +591,7 @@ public class PoiFiltersHelper {
if(!application.getPoiTypes().isInit()) {
return;
}
selectedPoiFilters.clear();
selectedPoiFilters = new TreeSet<>();
for (String f : application.getSettings().getSelectedPoiFilters()) {
PoiUIFilter filter = getFilterById(f);
if (filter != null) {
@ -602,7 +601,6 @@ public class PoiFiltersHelper {
selectedPoiFilters.add(filter);
}
}
updatePoiFiltersOnMap = true;
}
@Nullable
@ -640,16 +638,6 @@ public class PoiFiltersHelper {
application.getSettings().setSelectedPoiFilters(filters);
}
public boolean shouldUpdatePoiFiltersOnMap() {
boolean shouldUpdate = updatePoiFiltersOnMap;
updatePoiFiltersOnMap = false;
return shouldUpdate;
}
public void setUpdatePoiFiltersOnMap(boolean updatePoiFiltersOnMap) {
this.updatePoiFiltersOnMap = updatePoiFiltersOnMap;
}
public class PoiFilterDbHelper {
private static final int TRUE_INT = 1;

View file

@ -4,6 +4,7 @@ package net.osmand.plus.poi;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode;

View file

@ -205,10 +205,9 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
PoiFiltersHelper ph = app.getPoiFilters();
Set<PoiUIFilter> selectedPoiFilters = ph.getSelectedPoiFilters();
if (!this.filters.equals(selectedPoiFilters) || ph.shouldUpdatePoiFiltersOnMap()) {
this.filters = new TreeSet<>(selectedPoiFilters);
Set<PoiUIFilter> selectedPoiFilters = app.getPoiFilters().getSelectedPoiFilters();
if (this.filters != selectedPoiFilters) {
this.filters = selectedPoiFilters;
data.clearCache();
}

View file

@ -311,9 +311,7 @@ public class WikipediaPoiMenu {
public static void refreshWikipediaOnMap(MapActivity mapActivity) {
OsmandApplication app = mapActivity.getMyApplication();
hideWikipediaFromMap(app);
showWikipediaOnMap(app);
app.getPoiFilters().setUpdatePoiFiltersOnMap(true);
app.getPoiFilters().loadSelectedPoiFilters();
mapActivity.getDashboard().refreshContent(true);
mapActivity.refreshMap();
}
@ -321,6 +319,7 @@ public class WikipediaPoiMenu {
private static void showWikipediaOnMap(OsmandApplication app) {
PoiFiltersHelper ph = app.getPoiFilters();
PoiUIFilter wiki = ph.getTopWikiPoiFilter();
ph.loadSelectedPoiFilters();
ph.addSelectedPoiFilter(wiki);
}