forked from organicmaps/organicmaps-tmp
[android] Enum for pedestrian turn directions.
This commit is contained in:
parent
6b0262ab86
commit
464367dea8
2 changed files with 27 additions and 20 deletions
|
@ -2,8 +2,10 @@ package com.mapswithme.maps.routing;
|
|||
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
|
||||
public class RoutingInfo
|
||||
{
|
||||
|
@ -17,13 +19,14 @@ public class RoutingInfo
|
|||
// The next street according to the navigation route.
|
||||
public String mTargetName;
|
||||
|
||||
public TurnDirection mTurnDirection;
|
||||
public VehicleTurnDirection mVehicleTurnDirection;
|
||||
public final String[] turnNotifications;
|
||||
public PedestrianTurnDirection mPedestrianTurnDirection;
|
||||
|
||||
/**
|
||||
* IMPORTANT : Order of enum values MUST BE the same with native TurnDirection enum.
|
||||
*/
|
||||
public enum TurnDirection
|
||||
public enum VehicleTurnDirection
|
||||
{
|
||||
NO_TURN(R.drawable.ic_straight_compact),
|
||||
GO_STRAIGHT(R.drawable.ic_straight_compact),
|
||||
|
@ -48,36 +51,48 @@ public class RoutingInfo
|
|||
|
||||
private int mTurnRes;
|
||||
|
||||
TurnDirection(@DrawableRes int resId)
|
||||
VehicleTurnDirection(@DrawableRes int resId)
|
||||
{
|
||||
mTurnRes = resId;
|
||||
}
|
||||
|
||||
public
|
||||
@DrawableRes
|
||||
int getDrawableRes()
|
||||
public void setTurnDrawable(ImageView imageView)
|
||||
{
|
||||
return mTurnRes;
|
||||
imageView.setImageResource(mTurnRes);
|
||||
if (isLeftTurn(this))
|
||||
ViewHelper.setScaleX(imageView, -1); // right turns are displayed as mirrored left turns.
|
||||
else
|
||||
ViewHelper.setScaleX(imageView, 1);
|
||||
}
|
||||
|
||||
public static boolean isLeftTurn(TurnDirection turn)
|
||||
public static boolean isLeftTurn(VehicleTurnDirection turn)
|
||||
{
|
||||
return turn == TURN_LEFT || turn == TURN_SHARP_LEFT || turn == TURN_SLIGHT_LEFT;
|
||||
}
|
||||
|
||||
public static boolean isRightTurn(TurnDirection turn)
|
||||
public static boolean isRightTurn(VehicleTurnDirection turn)
|
||||
{
|
||||
return turn == TURN_RIGHT || turn == TURN_SHARP_RIGHT || turn == TURN_SLIGHT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
public enum PedestrianTurnDirection
|
||||
{
|
||||
NONE,
|
||||
UPSTAIRS,
|
||||
DOWNSTAIRS,
|
||||
LIFT_GATE,
|
||||
GATE,
|
||||
REACHED_YOUR_DESTINATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* IMPORTANT : Order of enum values MUST BE the same
|
||||
* with native LaneWay enum (see routing/turns.hpp for details).
|
||||
* Information for every lane is composed of some number values below.
|
||||
* For example, a lane may have THROUGH and RIGHT values.
|
||||
*/
|
||||
enum LaneWay
|
||||
public enum LaneWay
|
||||
{
|
||||
NONE,
|
||||
REVERSE,
|
||||
|
@ -92,8 +107,6 @@ public class RoutingInfo
|
|||
SHARP_RIGHT
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public RoutingInfo(String distToTarget, String units, String distTurn, String turnSuffix,
|
||||
String targetName, int direction, int totalTime, SingleLaneInfo[] lanes, String[] turnNotifications)
|
||||
{
|
||||
|
@ -103,11 +116,10 @@ public class RoutingInfo
|
|||
mDistToTurn = distTurn;
|
||||
mTargetName = targetName;
|
||||
mTotalTimeInSeconds = totalTime;
|
||||
mTurnDirection = TurnDirection.values()[direction];
|
||||
mVehicleTurnDirection = VehicleTurnDirection.values()[direction];
|
||||
this.turnNotifications = turnNotifications;
|
||||
}
|
||||
|
||||
|
||||
private void DumpLanes(SingleLaneInfo[] lanes)
|
||||
{
|
||||
for (int j = 0; j < lanes.length; j++)
|
||||
|
|
|
@ -25,7 +25,6 @@ import com.mapswithme.maps.bookmarks.data.MapObject;
|
|||
import com.mapswithme.maps.routing.RoutingInfo;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.statistics.AlohaHelper;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -239,11 +238,7 @@ public class RoutingLayout extends FrameLayout implements CompoundButton.OnCheck
|
|||
|
||||
mTvTurnDistance.setText(getSpannedDistance(getResources().getDimensionPixelSize(R.dimen.text_size_display_1),
|
||||
getResources().getDimensionPixelSize(R.dimen.text_size_toolbar), info.mDistToTurn, info.mTurnUnitsSuffix));
|
||||
mIvTurn.setImageResource(info.mTurnDirection.getDrawableRes());
|
||||
if (RoutingInfo.TurnDirection.isLeftTurn(info.mTurnDirection))
|
||||
ViewHelper.setScaleX(mIvTurn, -1); // right turns are displayed as mirrored left turns.
|
||||
else
|
||||
ViewHelper.setScaleX(mIvTurn, 1);
|
||||
info.mVehicleTurnDirection.setTurnDrawable(mIvTurn);
|
||||
|
||||
mTvTotalTime.setText(formatTime(info.mTotalTimeInSeconds));
|
||||
mTvTotalDistance.setText(new StringBuilder(info.mDistToTarget).append(" ").append(info.mUnits.toUpperCase()));
|
||||
|
|
Loading…
Add table
Reference in a new issue