From 0e76730e885c96104e0c989bb9be679fb0858276 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 8 Nov 2017 15:58:50 +0200 Subject: [PATCH] Move getting arrow width to widgets factory --- .../src/net/osmand/router/TurnType.java | 35 ----------------- .../mapwidgets/RouteInfoWidgetsFactory.java | 39 ++++++++++++++++++- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/TurnType.java b/OsmAnd-java/src/net/osmand/router/TurnType.java index 71be5a3c73..f7e7ae9766 100644 --- a/OsmAnd-java/src/net/osmand/router/TurnType.java +++ b/OsmAnd-java/src/net/osmand/router/TurnType.java @@ -413,41 +413,6 @@ public class TurnType { } } - public static int getArrowWidthInDp(int tt) { - int result; - - switch (tt){ - case TurnType.C: - result = 12; - break; - case TurnType.TR: - case TurnType.TL: - result = 20; - break; - case TurnType.KR: - case TurnType.KL: - result = 13; - break; - case TurnType.TSLR: - case TurnType.TSLL: - result = 13; - break; - case TurnType.TSHR: - case TurnType.TSHL: - result = 19; - break; - case TurnType.TRU: - case TurnType.TU: - result = 24; - break; - default: - result = 12; - break; - } - - return result; - } - public static int convertType(String lane) { int turn; if (lane.equals("none") || lane.equals("through")) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 2e196cae6e..f8e5c1214e 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -915,7 +915,7 @@ public class RouteInfoWidgetsFactory { secondTurnType, thirdTurnType, TurnPathHelper.FIRST_TURN, coef, leftSide); if (b != null) { if (secondTurnType == 0 && thirdTurnType == 0) { - int arrowWidth = AndroidUtils.dpToPx(ctx, TurnType.getArrowWidthInDp(turnType)); + int arrowWidth = AndroidUtils.dpToPx(ctx, getArrowWidthInDp(turnType)); int emptyWidth = b.getWidth() - arrowWidth; w += emptyWidth / 2 + arrowWidth; } else { @@ -1022,12 +1022,47 @@ public class RouteInfoWidgetsFactory { } private Bitmap applyCrop(Bitmap bitmap, int turnType) { - int arrowWidth = AndroidUtils.dpToPx(ctx, TurnType.getArrowWidthInDp(turnType)); + int arrowWidth = AndroidUtils.dpToPx(ctx, getArrowWidthInDp(turnType)); int emptyWidth = bitmap.getWidth() - arrowWidth; int widthToCrop = emptyWidth / 4; return Bitmap.createBitmap(bitmap, widthToCrop, 0, bitmap.getWidth() - 2 * widthToCrop, bitmap.getHeight()); } + private int getArrowWidthInDp(int tt) { + int result; + + switch (tt){ + case TurnType.C: + result = 12; + break; + case TurnType.TR: + case TurnType.TL: + result = 20; + break; + case TurnType.KR: + case TurnType.KL: + result = 13; + break; + case TurnType.TSLR: + case TurnType.TSLL: + result = 13; + break; + case TurnType.TSHR: + case TurnType.TSHL: + result = 19; + break; + case TurnType.TRU: + case TurnType.TU: + result = 24; + break; + default: + result = 12; + break; + } + + return result; + } + //@Override public void drawOld(Canvas canvas) { float w = 72 * scaleCoefficient / miniCoeff;