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