Esempio n. 1
0
    public boolean updateInfo(DrawSettings d) {
      String text = null;
      TurnType[] type = new TurnType[1];
      boolean showNextTurn = false;
      if (routingHelper != null && routingHelper.isRouteCalculated()) {
        if (routingHelper.isFollowingMode()) {
          if (settings.SHOW_STREET_NAME.get()) {
            text = routingHelper.getCurrentName(type);
            if (text == null) {
              text = "";
            }
          }
        } else {
          int di = MapRouteInfoMenu.getDirectionInfo();
          if (di >= 0
              && MapRouteInfoMenu.isControlVisible()
              && di < routingHelper.getRouteDirections().size()) {
            showNextTurn = true;
            RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
            type[0] = next.getTurnType();
            text =
                RoutingHelper.formatStreetName(
                    next.getStreetName(), next.getRef(), next.getDestinationName());
            //						if(next.distance > 0) {
            //							text += " " + OsmAndFormatter.getFormattedDistance(next.distance,
            // map.getMyApplication());
            //						}
            if (text == null) {
              text = "";
            }
          }
        }
      } else if (settings.getApplicationMode() != ApplicationMode.DEFAULT
          && map.getMapViewTrackingUtilities().isMapLinkedToLocation()
          && settings.SHOW_STREET_NAME.get()) {
        RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
        if (rt != null) {
          text =
              RoutingHelper.formatStreetName(
                  rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
                  rt.getRef(),
                  rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()));
        }
        if (text == null) {
          text = "";
        }
      }
      if (!showNextTurn && updateWaypoint()) {
        updateVisibility(true);
        updateVisibility(addressText, false);
        updateVisibility(addressTextShadow, false);
      } else if (text == null) {
        updateVisibility(false);
      } else {
        updateVisibility(true);
        updateVisibility(waypointInfoBar, false);
        updateVisibility(addressText, true);
        updateVisibility(addressTextShadow, shadowRad > 0);
        boolean update = turnDrawable.setTurnType(type[0]);

        int h = addressText.getHeight() / 4 * 3;
        if (h != turnDrawable.getBounds().bottom) {
          turnDrawable.setBounds(0, 0, h, h);
        }
        if (update) {
          if (type[0] != null) {
            addressTextShadow.setCompoundDrawables(turnDrawable, null, null, null);
            addressTextShadow.setCompoundDrawablePadding(4);
            addressText.setCompoundDrawables(turnDrawable, null, null, null);
            addressText.setCompoundDrawablePadding(4);
          } else {
            addressTextShadow.setCompoundDrawables(null, null, null, null);
            addressText.setCompoundDrawables(null, null, null, null);
          }
        }
        if (!text.equals(addressText.getText().toString())) {
          if (!text.equals("")) {
            topBar.setContentDescription(text);
          } else {
            topBar.setContentDescription(
                map.getResources().getString(R.string.map_widget_top_text));
          }
          addressTextShadow.setText(text);
          addressText.setText(text);
          return true;
        }
      }
      return false;
    }
 public boolean updateInfo(DrawSettings drawSettings) {
   boolean visible = false;
   int locimminent = -1;
   int[] loclanes = null;
   int dist = 0;
   // TurnType primary = null;
   if ((rh == null || !rh.isFollowingMode())
       && trackingUtilities.isMapLinkedToLocation()
       && settings.SHOW_LANES.get()) {
     RouteDataObject ro = locationProvider.getLastKnownRouteSegment();
     Location lp = locationProvider.getLastKnownLocation();
     if (ro != null) {
       float degree = lp == null || !lp.hasBearing() ? 0 : lp.getBearing();
       loclanes = RouteResultPreparation.parseTurnLanes(ro, degree / 180 * Math.PI);
       if (loclanes == null) {
         loclanes = RouteResultPreparation.parseLanes(ro, degree / 180 * Math.PI);
       }
     }
   } else if (rh != null && rh.isRouteCalculated()) {
     if (rh.isFollowingMode() && settings.SHOW_LANES.get()) {
       NextDirectionInfo r = rh.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
       if (r != null && r.directionInfo != null && r.directionInfo.getTurnType() != null) {
         loclanes = r.directionInfo.getTurnType().getLanes();
         // primary = r.directionInfo.getTurnType();
         locimminent = r.imminent;
         // Do not show too far
         if ((r.distanceTo > 800 && r.directionInfo.getTurnType().isSkipToSpeak())
             || r.distanceTo > 1200) {
           loclanes = null;
         }
         dist = r.distanceTo;
       }
     } else {
       int di = MapRouteInfoControl.getDirectionInfo();
       if (di >= 0
           && MapRouteInfoControl.isControlVisible()
           && di < rh.getRouteDirections().size()) {
         RouteDirectionInfo next = rh.getRouteDirections().get(di);
         if (next != null) {
           loclanes = next.getTurnType().getLanes();
           // primary = next.getTurnType();
         }
       }
     }
   }
   visible = loclanes != null && loclanes.length > 0;
   if (visible) {
     if (!Arrays.equals(lanesDrawable.lanes, loclanes)
         || (locimminent == 0) != lanesDrawable.imminent) {
       lanesDrawable.imminent = locimminent == 0;
       lanesDrawable.lanes = loclanes;
       lanesDrawable.updateBounds();
       lanesView.setImageDrawable(null);
       lanesView.setImageDrawable(lanesDrawable);
       lanesView.requestLayout();
       lanesView.invalidate();
     }
     if (distChanged(dist, this.dist)) {
       this.dist = dist;
       if (dist == 0) {
         lanesShadowText.setText("");
         lanesText.setText("");
       } else {
         lanesShadowText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
         lanesText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
       }
       lanesShadowText.invalidate();
       lanesText.invalidate();
     }
   }
   updateVisibility(lanesShadowText, visible && shadowRadius > 0);
   updateVisibility(lanesText, visible);
   updateVisibility(lanesView, visible);
   updateVisibility(centerInfo, visible || progress.getVisibility() == View.VISIBLE);
   return true;
 }