コード例 #1
0
  public void updateType(Amenity amenity) {
    poiTypeEditText.setText(amenity.getSubType());
    poiTypeTextInputLayout.setHint(amenity.getType().getTranslation());
    setAdapterForPoiTypeEditText();
    poiTypeEditText.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(final View v, MotionEvent event) {
            final EditText editText = (EditText) v;
            final int DRAWABLE_RIGHT = 2;
            if (event.getAction() == MotionEvent.ACTION_UP) {
              if (event.getX()
                  >= (editText.getRight()
                      - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
                      - editText.getPaddingRight())) {
                if (editPoiData.amenity.getType() != null) {
                  DialogFragment dialogFragment =
                      PoiSubTypeDialogFragment.createInstance(editPoiData.amenity);
                  dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment");
                }

                return true;
              }
            }
            return false;
          }
        });
  }
コード例 #2
0
ファイル: WaypointHelper.java プロジェクト: AmZaf/Osmand
 public Drawable getDrawable(Context uiCtx, OsmandApplication app) {
   if (type == POI) {
     Amenity amenity = ((AmenityLocationPoint) point).a;
     PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
     if (st != null) {
       if (RenderingIcons.containsBigIcon(st.getIconKeyName())) {
         return uiCtx
             .getResources()
             .getDrawable(RenderingIcons.getBigIconResourceId(st.getIconKeyName()));
       } else if (RenderingIcons.containsBigIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
         return uiCtx
             .getResources()
             .getDrawable(
                 RenderingIcons.getBigIconResourceId(st.getOsmTag() + "_" + st.getOsmValue()));
       }
     }
     return null;
   } else if (type == TARGETS) {
     int i =
         !((TargetPoint) point).intermediate
             ? R.drawable.list_destination
             : R.drawable.list_intermediate;
     return uiCtx.getResources().getDrawable(i);
   } else if (type == FAVORITES || type == WAYPOINTS) {
     return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false);
   } else if (type == ALARMS) {
     // assign alarm list icons manually for now
     if (((AlarmInfo) point).getType().toString() == "SPEED_CAMERA") {
       return uiCtx.getResources().getDrawable(R.drawable.mx_highway_speed_camera);
     } else if (((AlarmInfo) point).getType().toString() == "BORDER_CONTROL") {
       return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control);
     } else if (((AlarmInfo) point).getType().toString() == "RAILWAY") {
       if (app.getSettings().DRIVING_REGION.get().americanSigns) {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us);
       } else {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways);
       }
     } else if (((AlarmInfo) point).getType().toString() == "TRAFFIC_CALMING") {
       if (app.getSettings().DRIVING_REGION.get().americanSigns) {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us);
       } else {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming);
       }
     } else if (((AlarmInfo) point).getType().toString() == "TOLL_BOOTH") {
       return uiCtx.getResources().getDrawable(R.drawable.mx_toll_booth);
     } else if (((AlarmInfo) point).getType().toString() == "STOP") {
       return uiCtx.getResources().getDrawable(R.drawable.list_stop);
     } else if (((AlarmInfo) point).getType().toString() == "PEDESTRIAN") {
       if (app.getSettings().DRIVING_REGION.get().americanSigns) {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us);
       } else {
         return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian);
       }
     } else {
       return null;
     }
   } else {
     return null;
   }
 }
コード例 #3
0
ファイル: OsmAndFormatter.java プロジェクト: prqek/Osmand
  public static String getPoiStringWithoutType(Amenity amenity, boolean en) {
    String type = SpecialPhrases.getSpecialPhrase(amenity.getSubType());
    String n = amenity.getName(en);

    if (type == null) {
      type = amenity.getSubType();
    }
    if (n.indexOf(type) != -1) {
      // type is contained in name e.g.
      // n = "Bakery the Corner"
      // type = "Bakery"
      // no need to repeat this
      return n;
    }
    if (n.length() == 0) {
      return type;
    }
    return type + " " + n; // $NON-NLS-1$
  }
コード例 #4
0
  @Override
  public Node loadNode(Amenity n) {
    if (n.getId() % 2 == 1) {
      // that's way id
      return null;
    }
    long nodeId = n.getId() >> 1;

    //		EntityId id = new Entity.EntityId(EntityType.NODE, nodeId);
    Node entity = new Node(n.getLocation().getLatitude(), n.getLocation().getLongitude(), nodeId);

    Map<AmenityType, Map<String, String>> typeNameToTagVal =
        MapRenderingTypes.getDefault().getAmenityTypeNameToTagVal();
    AmenityType type = n.getType();
    String tag = type.getDefaultTag();
    String subType = n.getSubType();
    String val = subType;
    if (typeNameToTagVal.containsKey(type)) {
      Map<String, String> map = typeNameToTagVal.get(type);
      if (map.containsKey(subType)) {
        String res = map.get(subType);
        if (res != null) {
          int i = res.indexOf(' ');
          if (i != -1) {
            tag = res.substring(0, i);
            val = res.substring(i + 1);
          } else {
            tag = res;
          }
        }
      }
    }
    entity.putTag(tag, val);
    entity.putTag(OSMTagKey.NAME.getValue(), n.getName());
    entity.putTag(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours());

    // check whether this is node (because id of node could be the same as relation)
    if (entity != null && MapUtils.getDistance(entity.getLatLon(), n.getLocation()) < 50) {
      return entity;
    }
    return null;
  }
コード例 #5
0
ファイル: POIMapLayer.java プロジェクト: rogere66/Osmand
  @Override
  public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {

    if (view.getZoom() >= startZoom) {
      objects.clear();
      resourceManager.searchAmenitiesAsync(
          latLonBounds.top,
          latLonBounds.left,
          latLonBounds.bottom,
          latLonBounds.right,
          view.getZoom(),
          filter,
          objects);
      int r = getRadiusPoi(view.getZoom());
      for (Amenity o : objects) {
        int x =
            view.getRotatedMapXForPoint(
                o.getLocation().getLatitude(), o.getLocation().getLongitude());
        int y =
            view.getRotatedMapYForPoint(
                o.getLocation().getLatitude(), o.getLocation().getLongitude());
        canvas.drawCircle(x, y, r, pointAltUI);
        canvas.drawCircle(x, y, r, point);
        String id = null;
        if (RenderingIcons.containsIcon(o.getSubType())) {
          id = o.getSubType();
        } else if (RenderingIcons.containsIcon(
            o.getType().getDefaultTag() + "_" + o.getSubType())) {
          id = o.getType().getDefaultTag() + "_" + o.getSubType();
        }
        if (id != null) {
          Bitmap bmp = RenderingIcons.getIcon(view.getContext(), id);
          if (bmp != null) {
            canvas.drawBitmap(bmp, x - bmp.getWidth() / 2, y - bmp.getHeight() / 2, paintIcon);
          }
        }
      }

      if (view.getSettings().SHOW_POI_LABEL.get()) {
        TIntHashSet set = new TIntHashSet();
        for (Amenity o : objects) {
          int x =
              view.getRotatedMapXForPoint(
                  o.getLocation().getLatitude(), o.getLocation().getLongitude());
          int y =
              view.getRotatedMapYForPoint(
                  o.getLocation().getLatitude(), o.getLocation().getLongitude());
          int tx = view.getMapXForPoint(o.getLocation().getLongitude());
          int ty = view.getMapYForPoint(o.getLocation().getLatitude());
          String name = o.getName(view.getSettings().USE_ENGLISH_NAMES.get());
          if (name != null && name.length() > 0) {
            int lines = 0;
            while (lines < TEXT_LINES) {
              if (set.contains(division(tx, ty, 0, lines))
                  || set.contains(division(tx, ty, -1, lines))
                  || set.contains(division(tx, ty, +1, lines))) {
                break;
              }
              lines++;
            }
            if (lines == 0) {
              // drawWrappedText(canvas, "...", paintTextIcon.getTextSize(), x, y + r + 2 +
              // paintTextIcon.getTextSize() / 2, 1);
            } else {
              drawWrappedText(
                  canvas,
                  name,
                  paintTextIcon.getTextSize(),
                  x,
                  y + r + 2 + paintTextIcon.getTextSize() / 2,
                  lines);
              while (lines > 0) {
                set.add(division(tx, ty, 1, lines - 1));
                set.add(division(tx, ty, -1, lines - 1));
                set.add(division(tx, ty, 0, lines - 1));
                lines--;
              }
            }
          }
        }
      }
    }
  }