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

View file

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

View file

@ -205,10 +205,9 @@ 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) {
PoiFiltersHelper ph = app.getPoiFilters(); Set<PoiUIFilter> selectedPoiFilters = app.getPoiFilters().getSelectedPoiFilters();
Set<PoiUIFilter> selectedPoiFilters = ph.getSelectedPoiFilters(); if (this.filters != selectedPoiFilters) {
if (!this.filters.equals(selectedPoiFilters) || ph.shouldUpdatePoiFiltersOnMap()) { this.filters = selectedPoiFilters;
this.filters = new TreeSet<>(selectedPoiFilters);
data.clearCache(); data.clearCache();
} }

View file

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