Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e92e10fb2d
6 changed files with 33 additions and 13 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>()));
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
helper.editPoiFilter(filter);
|
||||
ListView lv = this.getListView();
|
||||
AmenityAdapter la = this.getListAdapter();
|
||||
la.notifyDataSetInvalidated();
|
||||
la.notifyDataSetChanged();
|
||||
return lv;
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
for (int i = 0; i < count; i++) {
|
||||
selectAllFromCategory(adapter.getItem(i));
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void deselectAll(){
|
||||
|
|
|
@ -345,7 +345,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
PoiUIFilter custom = getMyApplication().getPoiFilters().getCustomPOIFilter();
|
||||
custom.updateTypesToAccept(f);
|
||||
custom.replaceWithPoiFilter(f);
|
||||
showEditActivity(custom);
|
||||
return true;
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
this.filter.setFilterByName(null);
|
||||
}
|
||||
} else {
|
||||
this.filter.updateTypesToAccept(custom);
|
||||
this.filter.replaceWithPoiFilter(custom);
|
||||
}
|
||||
filter.clearPreviousZoom();
|
||||
// run query again
|
||||
|
|
|
@ -194,6 +194,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
|
|||
} else {
|
||||
custom.setFilterByName(null);
|
||||
}
|
||||
custom.clearFilter();
|
||||
custom.updateTypesToAccept(((AbstractPoiType) item));
|
||||
showFilterActivity(custom.getFilterId());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -449,9 +449,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
|
||||
|
||||
public void updateTypesToAccept(AbstractPoiType pt) {
|
||||
acceptedTypes.clear();
|
||||
pt.putTypes(acceptedTypes);
|
||||
poiAdditionals.clear();
|
||||
if (pt instanceof PoiType && ((PoiType) pt).isAdditional() && ((PoiType) pt).getParentType() != null) {
|
||||
fillPoiAdditionals(((PoiType) pt).getParentType());
|
||||
} else {
|
||||
|
@ -488,7 +486,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateTypesToAccept(PoiUIFilter f) {
|
||||
public void replaceWithPoiFilter(PoiUIFilter f) {
|
||||
acceptedTypes.clear();
|
||||
acceptedTypes.putAll(f.acceptedTypes);
|
||||
poiAdditionals.clear();
|
||||
|
|
Loading…
Reference in a new issue