コード例 #1
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  /**
   * Sets ending point.
   *
   * <ul>
   *   <li>If {@code point} is the same as starting point &mdash; swap points if ending point is
   *       set, skip otherwise.
   *   <li>Set starting point to MyPosition if it was not set before.
   * </ul>
   *
   * Route starts to build if both points were set.
   *
   * @return {@code true} if the point was set.
   */
  @SuppressWarnings("Duplicates")
  public boolean setEndPoint(MapObject point) {
    mLogger.d("setEndPoint");

    if (MapObject.same(mEndPoint, point)) {
      if (mStartPoint == null) return setStartFromMyPosition();

      mLogger.d("setEndPoint: skip the same end point");
      return false;
    }

    if (point != null && point.sameAs(mStartPoint)) {
      if (mEndPoint == null) {
        mLogger.d("setEndPoint: skip because end point is empty");
        return false;
      }

      mLogger.d("setEndPoint: swap with starting point");
      mStartPoint = mEndPoint;
    }

    mEndPoint = point;

    if (mStartPoint == null) return setStartFromMyPosition();

    setPointsInternal();
    checkAndBuildRoute();
    return true;
  }
コード例 #2
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  private boolean setStartFromMyPosition() {
    mLogger.d("setStartFromMyPosition");

    MapObject my = LocationHelper.INSTANCE.getMyPosition();
    if (my == null) {
      mLogger.d("setStartFromMyPosition: no my position - skip");

      if (mContainer != null) mContainer.updatePoints();

      setPointsInternal();
      return false;
    }

    return setStartPoint(my);
  }
コード例 #3
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  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();
  }
コード例 #4
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  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();
            }
          });
  }
コード例 #5
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  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());
  }
コード例 #6
0
ファイル: RoutingController.java プロジェクト: syershov/omim
 void searchPoi(int slotId) {
   mLogger.d("searchPoi: " + slotId);
   Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_SEARCH_POINT);
   AlohaHelper.logClick(AlohaHelper.ROUTING_SEARCH_POINT);
   mWaitingPoiPickSlot = slotId;
   mContainer.showSearch();
   mContainer.updateMenu();
 }
コード例 #7
0
ファイル: RoutingController.java プロジェクト: syershov/omim
 /**
  * Called from the native code
  *
  * @param info this object contains information about Uber products
  */
 @MainThread
 private void onUberInfoReceived(@NonNull UberInfo info) {
   mUberPlanning = false;
   mLogger.d("onUberInfoReceived uberInfo = " + info);
   if (mLastRouterType == Framework.ROUTER_TYPE_TAXI && mContainer != null) {
     mContainer.onUberInfoReceived(info);
     completeUberRequest();
   }
 }
コード例 #8
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  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();
  }
コード例 #9
0
ファイル: RoutingController.java プロジェクト: syershov/omim
 /**
  * Called from the native code
  *
  * @param errorCode must match the one of the values in {@link
  *     com.mapswithme.maps.uber.Uber.ErrorCode}
  */
 @MainThread
 private void onUberError(@NonNull String errorCode) {
   mUberPlanning = false;
   Uber.ErrorCode code = Uber.ErrorCode.valueOf(errorCode);
   mLogger.e("onUberError error = " + code);
   if (mLastRouterType == Framework.ROUTER_TYPE_TAXI && mContainer != null) {
     mContainer.onUberError(code);
     completeUberRequest();
   }
 }
コード例 #10
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  public boolean cancelPlanning() {
    mLogger.d("cancelPlanning");

    if (isPlanning()) {
      cancel();
      return true;
    }

    return false;
  }
コード例 #11
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  public void setRouterType(@Framework.RouterType int router) {
    mLogger.d("setRouterType: " + mLastRouterType + " -> " + router);

    // Repeating tap on Uber icon should trigger the route building always,
    // because it may be "No internet connection, try later" case
    if (router == mLastRouterType && router != Framework.ROUTER_TYPE_TAXI) return;

    mLastRouterType = router;
    Framework.nativeSetRouter(router);

    if (mStartPoint != null && mEndPoint != null) build();
  }
コード例 #12
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  void swapPoints() {
    mLogger.d("swapPoints");

    MapObject point = mStartPoint;
    mStartPoint = mEndPoint;
    mEndPoint = point;

    Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_SWAP_POINTS);
    AlohaHelper.logClick(AlohaHelper.ROUTING_SWAP_POINTS);

    setPointsInternal();
    checkAndBuildRoute();
  }
コード例 #13
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  public boolean cancel() {
    if (isPlanning()) {
      mLogger.d("cancel: planning");

      cancelInternal();
      if (mContainer != null) mContainer.showRoutePlan(false, null);
      return true;
    }

    if (isNavigating()) {
      mLogger.d("cancel: navigating");

      cancelInternal();
      if (mContainer != null) {
        mContainer.showNavigation(false);
        mContainer.updateMenu();
      }
      return true;
    }

    mLogger.d("cancel: none");
    return false;
  }
コード例 #14
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  private void cancelInternal() {
    mLogger.d("cancelInternal");

    mStartPoint = null;
    mEndPoint = null;
    setPointsInternal();
    mWaitingPoiPickSlot = NO_SLOT;
    mUberRequestHandled = false;

    setBuildState(BuildState.NONE);
    setState(State.NONE);

    ThemeSwitcher.restart();
    Framework.nativeCloseRouting();
    LocationHelper.INSTANCE.restart();
  }
コード例 #15
0
ファイル: RoutingController.java プロジェクト: syershov/omim
        @Override
        public void onRoutingEvent(final int resultCode, @Nullable final String[] missingMaps) {
          mLogger.d("onRoutingEvent(resultCode: " + resultCode + ")");

          UiThread.run(
              new Runnable() {
                @Override
                public void run() {
                  mLastResultCode = resultCode;
                  mLastMissingMaps = missingMaps;
                  mContainsCachedResult = true;

                  if (mLastResultCode == ResultCodesHelper.NO_ERROR) {
                    mCachedRoutingInfo = Framework.nativeGetRouteFollowingInfo();
                    setBuildState(BuildState.BUILT);
                    mLastBuildProgress = 100;
                  }

                  processRoutingEvent();
                }
              });
        }
コード例 #16
0
ファイル: RoutingController.java プロジェクト: syershov/omim
  private void setState(State newState) {
    mLogger.d("[S] State: " + mState + " -> " + newState + ", BuildState: " + mBuildState);
    mState = newState;

    if (mContainer != null) mContainer.updateMenu();
  }