@NonNull
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
   AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
   final PoiCategory a =
       poiTypes.getPoiCategoryByName((String) getArguments().getSerializable(KEY_POI_CATEGORY));
   Set<String> strings = new TreeSet<>();
   if (a == poiTypes.getOtherPoiCategory()) {
     for (PoiCategory category : poiTypes.getCategories(false)) {
       if (!category.isNotEditableOsm()) {
         addCategory(category, strings);
       }
     }
   } else {
     addCategory(a, strings);
   }
   final String[] subCats = strings.toArray(new String[strings.size()]);
   builder.setItems(
       subCats,
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           ((EditPoiDialogFragment) getParentFragment()).setSubCategory(subCats[which]);
           dismiss();
         }
       });
   return builder.create();
 }
 @NonNull
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
   final Amenity amenity = (Amenity) getArguments().getSerializable(KEY_AMENITY);
   AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
   final List<PoiCategory> categories = poiTypes.getCategories(false);
   ArrayList<String> vals = new ArrayList<>(categories.size());
   ArrayList<PoiCategory> toDelete = new ArrayList<>();
   // TODO replace with constants
   for (PoiCategory category : categories) {
     if (category.getKeyName().equals("user_defined_other")
         || category.getKeyName().equals("osmwiki")) {
       toDelete.add(category);
     } else {
       vals.add(category.getTranslation());
     }
   }
   categories.removeAll(toDelete);
   builder.setItems(
       vals.toArray(new String[vals.size()]),
       new Dialog.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           PoiCategory aType = categories.get(which);
           if (aType != amenity.getType()) {
             amenity.setType(aType);
             amenity.setSubType(""); // $NON-NLS-1$
             ((EditPoiDialogFragment) getParentFragment()).updateType(amenity);
           }
           dismiss();
         }
       });
   return builder.create();
 }
 public static PoiSubTypeDialogFragment createInstance(PoiCategory cat) {
   PoiSubTypeDialogFragment fragment = new PoiSubTypeDialogFragment();
   Bundle args = new Bundle();
   args.putSerializable(KEY_POI_CATEGORY, cat.getKeyName());
   fragment.setArguments(args);
   return fragment;
 }
 private void addCategory(final PoiCategory a, Set<String> strings) {
   for (PoiType s : a.getPoiTypes()) {
     if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) {
       strings.add(s.getTranslation());
     }
   }
 }
Exemple #5
0
 @Override
 public String toString() {
   return type.getKeyName() + " : " + subType + " " + getName();
 }
Exemple #6
0
 @Override
 public String toStringEn() {
   return super.toStringEn() + ":" + type.getKeyName() + ":" + subType;
 }