Fix issues related to poi editing

This commit is contained in:
Victor Shcherb 2015-11-18 21:43:12 +01:00
parent 0b381243b1
commit b4981eecb5
2 changed files with 8 additions and 9 deletions

View file

@ -2,6 +2,8 @@ package net.osmand.plus.osmedit.dialogs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
@ -24,7 +26,7 @@ public class PoiSubTypeDialogFragment extends DialogFragment {
MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes(); MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final PoiCategory a = poiTypes.getPoiCategoryByName((String) getArguments().getSerializable(KEY_POI_CATEGORY)); final PoiCategory a = poiTypes.getPoiCategoryByName((String) getArguments().getSerializable(KEY_POI_CATEGORY));
List<String> strings = new ArrayList<>(); Set<String> strings = new TreeSet<>();
for (PoiType s : a.getPoiTypes()) { for (PoiType s : a.getPoiTypes()) {
if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) { if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) {
strings.add(s.getTranslation()); strings.add(s.getTranslation());

View file

@ -21,17 +21,14 @@ public class PoiTypeDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes(); MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final List<PoiCategory> categories = poiTypes.getCategories(false); final List<PoiCategory> categories = new ArrayList<PoiCategory>();
ArrayList<String> vals = new ArrayList<>(categories.size()); ArrayList<String> vals = new ArrayList<>();
ArrayList<PoiCategory> toDelete = new ArrayList<>(); for (PoiCategory category : poiTypes.getCategories(false)) {
for (PoiCategory category : categories) { if (!category.isNotEditableOsm()) {
if (category.isNotEditableOsm()) {
toDelete.add(category);
} else {
vals.add(category.getTranslation()); vals.add(category.getTranslation());
categories.add(category);
} }
} }
categories.removeAll(toDelete);
builder.setItems(vals.toArray(new String[vals.size()]), new Dialog.OnClickListener() { builder.setItems(vals.toArray(new String[vals.size()]), new Dialog.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {