Exemplo n.º 1
0
  public void prepare(@Nullable MapObject startPoint, @Nullable MapObject endPoint) {
    mLogger.d("prepare (" + (endPoint == null ? "route)" : "p2p)"));

    if (!Config.isRoutingDisclaimerAccepted()) {
      showDisclaimer(startPoint, endPoint);
      return;
    }

    cancel();
    mStartPoint = startPoint;
    mEndPoint = endPoint;
    setState(State.PREPARE);

    if (mStartPoint != null && mEndPoint != null)
      mLastRouterType =
          Framework.nativeGetBestRouter(
              mStartPoint.getLat(), mStartPoint.getLon(),
              mEndPoint.getLat(), mEndPoint.getLon());
    Framework.nativeSetRouter(mLastRouterType);

    if (mContainer != null)
      mContainer.showRoutePlan(
          true,
          new Runnable() {
            @Override
            public void run() {
              if (mStartPoint == null || mEndPoint == null) updatePlan();
              else build();
            }
          });
  }
Exemplo n.º 2
0
  private void build() {
    mLogger.d("build");
    mUberRequestHandled = false;
    mLastBuildProgress = 0;
    mInternetConnected = ConnectionState.isConnected();

    if (mLastRouterType == Framework.ROUTER_TYPE_TAXI) {
      if (!mInternetConnected) {
        completeUberRequest();
        return;
      }
      requestUberInfo();
    }

    setBuildState(BuildState.BUILDING);
    updatePlan();

    Statistics.INSTANCE.trackRouteBuild(mLastRouterType, mStartPoint, mEndPoint);
    org.alohalytics.Statistics.logEvent(
        AlohaHelper.ROUTING_BUILD,
        new String[] {
          Statistics.EventParam.FROM, Statistics.getPointType(mStartPoint),
          Statistics.EventParam.TO, Statistics.getPointType(mEndPoint)
        });
    Framework.nativeBuildRoute(
        mStartPoint.getLat(), mStartPoint.getLon(), mEndPoint.getLat(), mEndPoint.getLon());
  }
Exemplo n.º 3
0
 @NonNull
 UberLinks getUberLink(@NonNull String productId) {
   return Uber.nativeGetUberLinks(
       productId,
       mStartPoint.getLat(),
       mStartPoint.getLon(),
       mEndPoint.getLat(),
       mEndPoint.getLon());
 }
Exemplo n.º 4
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);
  }
Exemplo n.º 5
0
 private void requestUberInfo() {
   mUberPlanning = true;
   Uber.nativeRequestUberProducts(
       mStartPoint.getLat(), mStartPoint.getLon(), mEndPoint.getLat(), mEndPoint.getLon());
   if (mContainer != null) mContainer.updateBuildProgress(0, mLastRouterType);
 }