forked from organicmaps/organicmaps
[android] Added 'canUseMyPositionAsStart' parameter
When a user builds a route from the map his current position can be used as the start point. But if the user is in P2P mode we shouldn't do any assumptions about the start point, i.e. he should do it by himself.
This commit is contained in:
parent
402be49ff0
commit
94eb773841
3 changed files with 18 additions and 17 deletions
|
@ -753,14 +753,16 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return false;
|
||||
}
|
||||
|
||||
public void startLocationToPoint(String statisticsEvent, String alohaEvent, final @Nullable MapObject endPoint)
|
||||
public void startLocationToPoint(String statisticsEvent, String alohaEvent,
|
||||
final @Nullable MapObject endPoint,
|
||||
final boolean canUseMyPositionAsStart)
|
||||
{
|
||||
closeMenu(statisticsEvent, alohaEvent, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
RoutingController.get().prepare(endPoint);
|
||||
RoutingController.get().prepare(canUseMyPositionAsStart, endPoint);
|
||||
|
||||
if (mPlacePage != null && (mPlacePage.isDocked() || !mPlacePage.isFloating()))
|
||||
closePlacePage();
|
||||
|
@ -838,7 +840,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
break;
|
||||
|
||||
case P2P:
|
||||
startLocationToPoint(Statistics.EventName.MENU_P2P, AlohaHelper.MENU_POINT2POINT, null);
|
||||
startLocationToPoint(Statistics.EventName.MENU_P2P, AlohaHelper.MENU_POINT2POINT,
|
||||
null /* endPoint */, false /* canUseMyPositionAsStart */);
|
||||
break;
|
||||
|
||||
case BOOKMARKS:
|
||||
|
@ -2327,16 +2330,18 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mLatFrom != null && mLonFrom != null && routerType >= 0)
|
||||
{
|
||||
RoutingController.get().prepare(fromLatLon(mLatFrom, mLonFrom, mSaddr),
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), routerType, true);
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), routerType,
|
||||
true /* fromApi */);
|
||||
}
|
||||
else if (mLatFrom != null && mLonFrom != null)
|
||||
{
|
||||
RoutingController.get().prepare(fromLatLon(mLatFrom, mLonFrom, mSaddr),
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), true);
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), true /* fromApi */);
|
||||
}
|
||||
else
|
||||
{
|
||||
RoutingController.get().prepare(fromLatLon(mLatTo, mLonTo, mDaddr), true);
|
||||
RoutingController.get().prepare(true /* canUseMyPositionAsStart */,
|
||||
fromLatLon(mLatTo, mLonTo, mDaddr), true /* fromApi */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -376,14 +376,15 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
Framework.nativeSaveRoutePoints();
|
||||
}
|
||||
|
||||
public void prepare(@Nullable MapObject endPoint)
|
||||
public void prepare(boolean canUseMyPositionAsStart, @Nullable MapObject endPoint)
|
||||
{
|
||||
prepare(endPoint, false);
|
||||
prepare(canUseMyPositionAsStart, endPoint, false);
|
||||
}
|
||||
|
||||
public void prepare(@Nullable MapObject endPoint, boolean fromApi)
|
||||
public void prepare(boolean canUseMyPositionAsStart, @Nullable MapObject endPoint, boolean fromApi)
|
||||
{
|
||||
prepare(LocationHelper.INSTANCE.getMyPosition(), endPoint, fromApi);
|
||||
MapObject startPoint = canUseMyPositionAsStart ? LocationHelper.INSTANCE.getMyPosition() : null;
|
||||
prepare(startPoint, endPoint, fromApi);
|
||||
}
|
||||
|
||||
public void prepare(@Nullable MapObject startPoint, @Nullable MapObject endPoint)
|
||||
|
@ -888,9 +889,6 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
|
||||
if (isSamePoint)
|
||||
{
|
||||
if (getStartPoint() == null)
|
||||
return setStartFromMyPosition();
|
||||
|
||||
mLogger.d(TAG, "setEndPoint: skip the same end point");
|
||||
return false;
|
||||
}
|
||||
|
@ -914,9 +912,6 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
trackPointAdd(endPoint, RoutePointInfo.ROUTE_MARK_FINISH, isPlanning(), isNavigating(),
|
||||
false);
|
||||
|
||||
if (startPoint == null)
|
||||
return setStartFromMyPosition();
|
||||
|
||||
setPointsInternal(startPoint, endPoint);
|
||||
checkAndBuildRoute();
|
||||
return true;
|
||||
|
|
|
@ -578,7 +578,8 @@ public class PlacePageView extends RelativeLayout
|
|||
}
|
||||
else
|
||||
{
|
||||
getActivity().startLocationToPoint(Statistics.EventName.PP_ROUTE, AlohaHelper.PP_ROUTE, getMapObject());
|
||||
getActivity().startLocationToPoint(Statistics.EventName.PP_ROUTE, AlohaHelper.PP_ROUTE,
|
||||
getMapObject(), true /* canUseMyPositionAsStart */);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue