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;
public static boolean makeUturnWhenPossible = false;
public static boolean suppressTurnPrompt = false;
public static int turnImminent = 0;
// TODO vshcherb review !
private boolean makeUturnWhenPossible = false;
private boolean suppressTurnPrompt = false;
private int turnImminent = 0;
private long makeUTwpDetected = 0;
public static boolean makeUturnWhenPossible() {
public boolean makeUturnWhenPossible() {
return makeUturnWhenPossible;
}
public static boolean suppressTurnPrompt() {
public boolean suppressTurnPrompt() {
return suppressTurnPrompt;
}
public static int turnImminent() {
public int turnImminent() {
return turnImminent;
}

View file

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

View file

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