update poi types selection (taking into account map=true) elements
This commit is contained in:
parent
9c08684385
commit
297a997761
4 changed files with 27 additions and 7 deletions
|
@ -28,6 +28,7 @@ public class MapPoiTypes {
|
|||
private String resourceName;
|
||||
private List<PoiCategory> categories = new ArrayList<PoiCategory>();
|
||||
private PoiCategory otherCategory;
|
||||
private PoiCategory otherMapCategory;
|
||||
|
||||
static final String OSM_WIKI_CATEGORY = "osmwiki";
|
||||
private PoiTranslator poiTranslator = null;
|
||||
|
@ -67,6 +68,13 @@ public class MapPoiTypes {
|
|||
return otherCategory;
|
||||
}
|
||||
|
||||
public PoiCategory getOtherMapCategory() {
|
||||
if(otherMapCategory == null) {
|
||||
otherMapCategory = getPoiCategoryByName("Other", true);
|
||||
}
|
||||
return otherMapCategory;
|
||||
}
|
||||
|
||||
public List<PoiFilter> getTopVisibleFilters() {
|
||||
List<PoiFilter> lf = new ArrayList<PoiFilter>();
|
||||
for(PoiCategory pc : categories) {
|
||||
|
@ -143,6 +151,9 @@ public class MapPoiTypes {
|
|||
public Map<String, AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
|
||||
TreeMap<String, AbstractPoiType> tm = new TreeMap<String, AbstractPoiType>(Collator.getInstance());
|
||||
for (PoiCategory pc : categories) {
|
||||
if(pc == otherMapCategory) {
|
||||
continue;
|
||||
}
|
||||
addIf(tm, pc, matcher);
|
||||
for (PoiFilter pt : pc.getPoiFilters()) {
|
||||
addIf(tm, pt, matcher);
|
||||
|
@ -290,6 +301,9 @@ public class MapPoiTypes {
|
|||
lastFilter.addPoiType(tp);
|
||||
}
|
||||
allTypes.put(tp.getKeyName(), tp);
|
||||
if(lastCategory == null) {
|
||||
lastCategory = getOtherMapCategory();
|
||||
}
|
||||
lastCategory.addPoiType(tp);
|
||||
}
|
||||
} else if (tok == XmlPullParser.END_TAG) {
|
||||
|
@ -298,6 +312,8 @@ public class MapPoiTypes {
|
|||
lastFilter = null;
|
||||
} else if (name.equals("poi_type")) {
|
||||
lastType = null;
|
||||
} else if (name.equals("poi_category")) {
|
||||
lastCategory = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,13 +352,17 @@ public class MapPoiTypes {
|
|||
otherCategory = pc;
|
||||
}
|
||||
|
||||
public List<PoiCategory> getCategories() {
|
||||
return categories;
|
||||
public List<PoiCategory> getCategories(boolean includeMapCategory) {
|
||||
ArrayList<PoiCategory> lst = new ArrayList<PoiCategory>(categories);
|
||||
if(!includeMapCategory) {
|
||||
lst.remove(getOtherMapCategory());
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
||||
private static void print(MapPoiTypes df) {
|
||||
List<PoiCategory> pc = df.getCategories();
|
||||
List<PoiCategory> pc = df.getCategories(true);
|
||||
for(PoiCategory p : pc) {
|
||||
System.out.println("Category " + p.getKeyName());
|
||||
for(PoiFilter f : p.getPoiFilters()) {
|
||||
|
|
|
@ -74,7 +74,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
|
||||
if (filter != null) {
|
||||
getSupportActionBar().setSubtitle(filter.getName());
|
||||
setListAdapter(new AmenityAdapter( ((OsmandApplication) getApplication()).getPoiTypes().getCategories()));
|
||||
setListAdapter(new AmenityAdapter( ((OsmandApplication) getApplication()).getPoiTypes().getCategories(false)));
|
||||
} else {
|
||||
setListAdapter(new AmenityAdapter(new ArrayList<PoiCategory>()));
|
||||
}
|
||||
|
|
|
@ -731,7 +731,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
|||
case DIALOG_POI_TYPES: {
|
||||
final Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||
Builder builder = new AlertDialog.Builder(activity);
|
||||
final List<PoiCategory> categories = poiTypes.getCategories();
|
||||
final List<PoiCategory> categories = poiTypes.getCategories(true);
|
||||
String[] vals = new String[categories.size()];
|
||||
for (int i = 0; i < vals.length; i++) {
|
||||
vals[i] = categories.get(i).getTranslation();
|
||||
|
|
|
@ -167,7 +167,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
}
|
||||
|
||||
private void initSearchAll(){
|
||||
for(PoiCategory t : poiTypes.getCategories()){
|
||||
for(PoiCategory t : poiTypes.getCategories(false)){
|
||||
acceptedTypes.put(t, null);
|
||||
}
|
||||
distanceToSearchValues = new double[] {0.5, 1, 2, 5, 10, 20, 50, 100};
|
||||
|
@ -436,7 +436,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
}
|
||||
|
||||
public boolean areAllTypesAccepted(){
|
||||
if(poiTypes.getCategories().size() == acceptedTypes.size()){
|
||||
if(poiTypes.getCategories(false).size() == acceptedTypes.size()){
|
||||
for(PoiCategory a : acceptedTypes.keySet()){
|
||||
if(acceptedTypes.get(a) != null){
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue