コード例 #1
0
  @Override
  protected void onResume() {
    super.onResume();
    Intent intent = getIntent();
    LatLon startPoint = null;
    if (intent != null) {
      double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
      double lon = intent.getDoubleExtra(SEARCH_LON, 0);
      if (lat != 0 || lon != 0) {
        startPoint = new LatLon(lat, lon);
      }
    }
    if (startPoint == null && getParent() instanceof SearchActivity) {
      startPoint = ((SearchActivity) getParent()).getSearchPoint();
    }
    if (startPoint == null) {
      startPoint = settings.getLastKnownMapLocation();
    }

    LatLon pointToNavigate = settings.getPointToNavigate();
    if (!Algoritms.objectEquals(pointToNavigate, this.destinationLocation)
        || !Algoritms.objectEquals(startPoint, this.lastKnownMapLocation)) {
      destinationLocation = pointToNavigate;
      selectedDestinationLocation = destinationLocation;
      lastKnownMapLocation = startPoint;
      searchTransport();
    }
  }
コード例 #2
0
 @Override
 public void locationUpdate(LatLon l) {
   if (!Algoritms.objectEquals(l, this.lastKnownMapLocation)) {
     lastKnownMapLocation = l;
     searchTransport();
   }
 }
コード例 #3
0
ファイル: MapInfoLayer.java プロジェクト: Muxagen/Osmand
  private void drawRouteInfo(Canvas canvas) {
    if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) {
      if (routeLayer.getHelper().isFollowingMode()) {
        int d = routeLayer.getHelper().getDistanceToNextRouteDirection();
        if (showMiniMap || d == 0) {
          if (!routeLayer.getPath().isEmpty()) {
            canvas.save();
            canvas.clipRect(boundsForMiniRoute);
            canvas.drawRoundRect(boundsForMiniRoute, roundCorner, roundCorner, paintAlphaGray);
            canvas.drawRoundRect(boundsForMiniRoute, roundCorner, roundCorner, paintBlack);
            canvas.translate(
                centerMiniRouteX - view.getCenterPointX(),
                centerMiniRouteY - view.getCenterPointY());
            canvas.scale(
                scaleMiniRoute, scaleMiniRoute, view.getCenterPointX(), view.getCenterPointY());
            canvas.rotate(view.getRotate(), view.getCenterPointX(), view.getCenterPointY());
            canvas.drawCircle(
                view.getCenterPointX(), view.getCenterPointY(), 3 / scaleMiniRoute, fillBlack);
            canvas.drawPath(routeLayer.getPath(), paintMiniRoute);
            canvas.restore();
          }
        } else {
          canvas.drawRoundRect(boundsForMiniRoute, roundCorner, roundCorner, paintAlphaGray);
          canvas.drawRoundRect(boundsForMiniRoute, roundCorner, roundCorner, paintBlack);
          RouteDirectionInfo next = routeLayer.getHelper().getNextRouteDirectionInfo();
          if (next != null) {
            if (!Algoritms.objectEquals(cachedTurnType, next.turnType)) {
              cachedTurnType = next.turnType;
              calcTurnPath(pathForTurn, cachedTurnType, pathTransform);
              if (cachedTurnType.getExitOut() > 0) {
                cachedExitOut = cachedTurnType.getExitOut() + ""; // $NON-NLS-1$
              } else {
                cachedExitOut = null;
              }
            }
            canvas.drawPath(pathForTurn, paintRouteDirection);
            canvas.drawPath(pathForTurn, paintBlack);
            if (cachedExitOut != null) {
              canvas.drawText(
                  cachedExitOut,
                  boundsForMiniRoute.centerX() - 6 * scaleCoefficient,
                  boundsForMiniRoute.centerY() - 9 * scaleCoefficient,
                  paintBlack);
            }
            canvas.drawText(
                OsmAndFormatter.getFormattedDistance(d, map),
                boundsForMiniRoute.left + 10 * scaleCoefficient,
                boundsForMiniRoute.bottom - 9 * scaleCoefficient,
                paintBlack);
          }
        }
      }

      boolean followingMode = routeLayer.getHelper().isFollowingMode();
      int time = routeLayer.getHelper().getLeftTime();
      if (time == 0) {
        cachedLeftTime = 0;
        cachedLeftTimeString = null;
      } else {
        if (followingMode && showArrivalTime) {
          long toFindTime = time * 1000 + System.currentTimeMillis();
          if (Math.abs(toFindTime - cachedLeftTime) > 30000) {
            cachedLeftTime = toFindTime;
            if (DateFormat.is24HourFormat(map)) {
              cachedLeftTimeString =
                  DateFormat.format("kk:mm", toFindTime).toString(); // $NON-NLS-1$
            } else {
              cachedLeftTimeString =
                  DateFormat.format("k:mm aa", toFindTime).toString(); // $NON-NLS-1$
            }
            boundsForLeftTime.left =
                -paintBlack.measureText(cachedLeftTimeString)
                    - 10 * scaleCoefficient
                    + boundsForLeftTime.right;
          }
        } else {
          if (Math.abs(time - cachedLeftTime) > 30) {
            cachedLeftTime = time;
            int hours = time / (60 * 60);
            int minutes = (time / 60) % 60;
            cachedLeftTimeString = String.format("%d:%02d", hours, minutes); // $NON-NLS-1$
            boundsForLeftTime.left =
                -paintBlack.measureText(cachedLeftTimeString)
                    - 10 * scaleCoefficient
                    + boundsForLeftTime.right;
          }
        }
      }
      if (cachedLeftTimeString != null) {
        int w = (int) (boundsForLeftTime.right - boundsForLeftTime.left);
        boundsForLeftTime.right = view.getWidth();
        boundsForLeftTime.left = view.getWidth() - w;
        canvas.drawRoundRect(boundsForLeftTime, roundCorner, roundCorner, paintAlphaGray);
        canvas.drawRoundRect(boundsForLeftTime, roundCorner, roundCorner, paintBlack);
        canvas.drawText(
            cachedLeftTimeString,
            boundsForLeftTime.left + 5 * scaleCoefficient,
            boundsForLeftTime.bottom - 9 * scaleCoefficient,
            paintBlack);
      }
    }
  }