Example #1
0
  public void start() {
    mLogger.d("start");

    if (!MapObject.isOfType(MapObject.MY_POSITION, mStartPoint)) {
      Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_START_SUGGEST_REBUILD);
      AlohaHelper.logClick(AlohaHelper.ROUTING_START_SUGGEST_REBUILD);
      suggestRebuildRoute();
      return;
    }

    MapObject my = LocationHelper.INSTANCE.getMyPosition();
    if (my == null) {
      mRoutingListener.onRoutingEvent(ResultCodesHelper.NO_POSITION, null);
      return;
    }

    mStartPoint = my;
    Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_START);
    AlohaHelper.logClick(AlohaHelper.ROUTING_START);
    setState(State.NAVIGATION);

    mContainer.showRoutePlan(false, null);
    mContainer.showNavigation(true);

    ThemeSwitcher.restart();

    Framework.nativeFollowRoute();
    LocationHelper.INSTANCE.restart();
  }
Example #2
0
  private void setBuildState(BuildState newState) {
    mLogger.d("[B] State: " + mState + ", BuildState: " + mBuildState + " -> " + newState);
    mBuildState = newState;

    if (mBuildState == BuildState.BUILT && !MapObject.isOfType(MapObject.MY_POSITION, mStartPoint))
      Framework.nativeDisableFollowing();

    if (mContainer != null) mContainer.updateMenu();
  }
Example #3
0
  private void setPointsInternal() {
    if (mStartPoint == null) Framework.nativeSetRouteStartPoint(0.0, 0.0, false);
    else
      Framework.nativeSetRouteStartPoint(
          mStartPoint.getLat(),
          mStartPoint.getLon(),
          !MapObject.isOfType(MapObject.MY_POSITION, mStartPoint));

    if (mEndPoint == null) Framework.nativeSetRouteEndPoint(0.0, 0.0, false);
    else Framework.nativeSetRouteEndPoint(mEndPoint.getLat(), mEndPoint.getLon(), true);
  }
Example #4
0
  private void suggestRebuildRoute() {
    final AlertDialog.Builder builder =
        new AlertDialog.Builder(mContainer.getActivity())
            .setMessage(R.string.p2p_reroute_from_current)
            .setCancelable(false)
            .setNegativeButton(R.string.cancel, null);

    TextView titleView =
        (TextView)
            View.inflate(mContainer.getActivity(), R.layout.dialog_suggest_reroute_title, null);
    titleView.setText(R.string.p2p_only_from_current);
    builder.setCustomTitle(titleView);

    if (MapObject.isOfType(MapObject.MY_POSITION, mEndPoint)) {
      builder.setPositiveButton(
          R.string.ok,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              swapPoints();
            }
          });
    } else {
      if (LocationHelper.INSTANCE.getMyPosition() == null)
        builder.setMessage(null).setNegativeButton(null, null);

      builder.setPositiveButton(
          R.string.ok,
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              setStartFromMyPosition();
            }
          });
    }

    builder.show();
  }