Update LanesDrawable

This commit is contained in:
y.ridkous@gmail.com 2016-03-28 00:06:41 +03:00
parent 19d42fba3e
commit 1203631e34
2 changed files with 13 additions and 8 deletions

View file

@ -11,6 +11,11 @@ import java.util.Map;
public class TurnPathHelper { public class TurnPathHelper {
//Index of processed turn
public static final int FIRST_TURN = 1;
public static final int SECOND_TURN = 2;
public static final int THIRD_TURN = 3;
// 72x72 // 72x72
public static void calcTurnPath(Path pathForTurn, TurnType turnType, Matrix transform) { public static void calcTurnPath(Path pathForTurn, TurnType turnType, Matrix transform) {
if(turnType == null){ if(turnType == null){
@ -400,7 +405,7 @@ public class TurnPathHelper {
} }
public static Bitmap getBitmapFromTurnType(Resources res, Map<TurnResource, Bitmap> cache, int firstTurn, int secondTurn, int thirdTurn, int turn, Bitmap defaultType, float coef, boolean leftSide) { public static Bitmap getBitmapFromTurnType(Resources res, Map<TurnResource, Bitmap> cache, int firstTurn, int secondTurn, int thirdTurn, int turnIndex, Bitmap defaultType, float coef, boolean leftSide) {
int firstTurnType = TurnType.valueOf(firstTurn, leftSide).getValue(); int firstTurnType = TurnType.valueOf(firstTurn, leftSide).getValue();
int secondTurnType = TurnType.valueOf(secondTurn, leftSide).getValue(); int secondTurnType = TurnType.valueOf(secondTurn, leftSide).getValue();
@ -408,7 +413,7 @@ public class TurnPathHelper {
TurnResource turnResource = new TurnResource(R.drawable.map_turn_forward_small, false); TurnResource turnResource = new TurnResource(R.drawable.map_turn_forward_small, false);
if(turn == 1){ if(turnIndex == FIRST_TURN){
if(firstTurn == 0) return defaultType; if(firstTurn == 0) return defaultType;
if(secondTurnType == 0) { if(secondTurnType == 0) {
turnResource = getTallArrow(firstTurnType); turnResource = getTallArrow(firstTurnType);
@ -422,14 +427,14 @@ public class TurnPathHelper {
// get the small one // get the small one
turnResource = getShortArrow(firstTurnType); turnResource = getShortArrow(firstTurnType);
} }
}else if(turn == 2){ }else if(turnIndex == SECOND_TURN){
if(firstTurnType == TurnType.C){ if(firstTurnType == TurnType.C || firstTurnType == TurnType.TR){
// get the small one // get the small one
turnResource = getShortArrow(secondTurnType); turnResource = getShortArrow(secondTurnType);
}else{ }else{
turnResource = getTallArrow(secondTurnType); turnResource = getTallArrow(secondTurnType);
} }
}else if(turn == 3){ }else if(turnIndex == THIRD_TURN){
if(secondTurnType == TurnType.C){ if(secondTurnType == TurnType.C){
// get the small one // get the small one
turnResource = getShortArrow(thirdTurnType); turnResource = getShortArrow(thirdTurnType);

View file

@ -649,7 +649,7 @@ public class RouteInfoWidgetsFactory {
this.scaleCoefficient = scaleCoefficent; this.scaleCoefficient = scaleCoefficent;
laneStraight = getPathFromTurnType(paths, TurnType.C, null, scaleCoefficient / miniCoeff); laneStraight = getPathFromTurnType(paths, TurnType.C, null, scaleCoefficient / miniCoeff);
laneStraightBitmap = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, TurnType.C, 0, 0, 1, null, scaleCoefficient / miniCoeff, leftSide); laneStraightBitmap = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, TurnType.C, 0, 0, TurnPathHelper.FIRST_TURN, null, scaleCoefficient / miniCoeff, leftSide);
paintBlack = new Paint(); paintBlack = new Paint();
paintBlack.setStyle(Style.STROKE); paintBlack.setStyle(Style.STROKE);
paintBlack.setColor(Color.BLACK); paintBlack.setColor(Color.BLACK);
@ -704,11 +704,11 @@ public class RouteInfoWidgetsFactory {
secondTurnType = TurnType.getSecondaryTurn(lanes[i]); secondTurnType = TurnType.getSecondaryTurn(lanes[i]);
float coef = scaleCoefficient / miniCoeff; float coef = scaleCoefficient / miniCoeff;
Bitmap b = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, turnType, secondTurnType, 0, 1, laneStraightBitmap, coef, leftSide); Bitmap b = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, turnType, secondTurnType, 0, TurnPathHelper.FIRST_TURN, laneStraightBitmap, coef, leftSide);
if(secondTurnType > 0){ if(secondTurnType > 0){
Bitmap bSecond = null; Bitmap bSecond = null;
bSecond = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, turnType, secondTurnType, 0, 2, laneStraightBitmap, coef, leftSide); bSecond = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, turnType, secondTurnType, 0, TurnPathHelper.SECOND_TURN, laneStraightBitmap, coef, leftSide);
if (bSecond != null){ if (bSecond != null){
paintSecondTurn.setColorFilter(new PorterDuffColorFilter(paintSecondTurn.getColor(), PorterDuff.Mode.SRC_ATOP)); paintSecondTurn.setColorFilter(new PorterDuffColorFilter(paintSecondTurn.getColor(), PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(bSecond, 0f, 0f, paintSecondTurn); canvas.drawBitmap(bSecond, 0f, 0f, paintSecondTurn);