Update view

This commit is contained in:
Victor Shcherb 2012-04-20 01:22:31 +02:00
parent b3cc557541
commit 11699b247a
3 changed files with 21 additions and 14 deletions

View file

@ -70,20 +70,22 @@ public class RoutingHelper {
private Handler uiHandler; private Handler uiHandler;
public static boolean makeUturnWhenPossible = false;
public static boolean suppressTurnPrompt = false; // TODO vshcherb review !
public static int turnImminent = 0; private boolean makeUturnWhenPossible = false;
private boolean suppressTurnPrompt = false;
private int turnImminent = 0;
private long makeUTwpDetected = 0; private long makeUTwpDetected = 0;
public static boolean makeUturnWhenPossible() { public boolean makeUturnWhenPossible() {
return makeUturnWhenPossible; return makeUturnWhenPossible;
} }
public static boolean suppressTurnPrompt() { public boolean suppressTurnPrompt() {
return suppressTurnPrompt; return suppressTurnPrompt;
} }
public static int turnImminent() { public int turnImminent() {
return turnImminent; return turnImminent;
} }

View file

@ -6,6 +6,7 @@ import net.osmand.OsmAndFormatter;
import net.osmand.osm.LatLon; import net.osmand.osm.LatLon;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.RouteDirectionInfo; import net.osmand.plus.routing.RoutingHelper.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper.TurnType; import net.osmand.plus.routing.RoutingHelper.TurnType;
import android.content.Context; import android.content.Context;
@ -425,17 +426,19 @@ public class MapInfoLayer extends OsmandMapLayer {
return miniMapControl; return miniMapControl;
} }
private NextTurnInfoControl createNextInfoControl() { private NextTurnInfoControl createNextInfoControl() {
final RoutingHelper routingHelper = routeLayer.getHelper();
final NextTurnInfoControl nextTurnInfo = new NextTurnInfoControl(map, paintText, paintSubText) { final NextTurnInfoControl nextTurnInfo = new NextTurnInfoControl(map, paintText, paintSubText) {
@Override @Override
public boolean updateInfo() { public boolean updateInfo() {
boolean visible = false; boolean visible = false;
if (routeLayer != null && routeLayer.getHelper().isRouterEnabled() && routeLayer.getHelper().isFollowingMode()) { if (routeLayer != null && routingHelper.isRouterEnabled() && routingHelper.isFollowingMode()) {
int d = routeLayer.getHelper().getDistanceToNextRouteDirection(); int d = routeLayer.getHelper().getDistanceToNextRouteDirection();
// Issue 863 makeUturnWhenPossible = routingHelper.makeUturnWhenPossible();
if (routeLayer.getHelper().makeUturnWhenPossible() == true) { if (routingHelper.makeUturnWhenPossible() == true) {
if (!showMiniMap) { if (!showMiniMap) {
visible = true; visible = true;
turnType = TurnType.valueOf(TurnType.TU); turnType = TurnType.valueOf(TurnType.TU);
@ -465,6 +468,10 @@ public class MapInfoLayer extends OsmandMapLayer {
invalidate(); invalidate();
nextTurnDirection = d; nextTurnDirection = d;
} }
if(turnImminent != routingHelper.turnImminent()){
turnImminent = routingHelper.turnImminent();
invalidate();
}
} }
} }
} }

View file

@ -1,6 +1,7 @@
package net.osmand.plus.views; package net.osmand.plus.views;
import net.osmand.OsmAndFormatter; import net.osmand.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.TurnType; import net.osmand.plus.routing.RoutingHelper.TurnType;
@ -31,8 +32,8 @@ public class NextTurnInfoControl extends MapInfoControl {
private Paint paintBlack; private Paint paintBlack;
private Paint paintRouteDirection; private Paint paintRouteDirection;
private boolean makeUturnWhenPossible; protected boolean makeUturnWhenPossible;
private int turnImminent; protected int turnImminent;
public NextTurnInfoControl(Context ctx, Paint textPaint, Paint subtextPaint) { public NextTurnInfoControl(Context ctx, Paint textPaint, Paint subtextPaint) {
super(ctx); super(ctx);
@ -66,7 +67,6 @@ public class NextTurnInfoControl extends MapInfoControl {
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
super.onDraw(canvas); super.onDraw(canvas);
if (pathForTurn != null) { if (pathForTurn != null) {
turnImminent = RoutingHelper.turnImminent();
if (turnImminent == 1) { if (turnImminent == 1) {
paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow_imminent)); paintRouteDirection.setColor(getResources().getColor(R.color.nav_arrow_imminent));
} else if (turnImminent == 0) { } else if (turnImminent == 0) {
@ -85,8 +85,6 @@ public class NextTurnInfoControl extends MapInfoControl {
String text = OsmAndFormatter.getFormattedDistance(nextTurnDirection, getContext()); String text = OsmAndFormatter.getFormattedDistance(nextTurnDirection, getContext());
String subtext = null; String subtext = null;
// Issue 863: distance "as soon as possible" should be displayed for unscheduled U-turn
makeUturnWhenPossible = RoutingHelper.makeUturnWhenPossible();
if (makeUturnWhenPossible == true) { if (makeUturnWhenPossible == true) {
text = "ASAP"; text = "ASAP";
} }