@Test public void onApproachInstruction_shouldNotFireForDestination() throws Exception { routeEngine.onLocationChanged(route.getRouteInstructions().get(3).getLocation()); assertThat(listener.approachIndex).isNotEqualTo(3); }
public void onLocationChanged(final ValhallaLocation location) { if (routeState == RouteState.COMPLETE) { return; } this.location = location; snapLocation(); if (routeState == RouteState.COMPLETE) { listener.onUpdateDistance(0, 0); } else { listener.onUpdateDistance(route.getDistanceToNextInstruction(), route.getRemainingDistanceToDestination()); } if (routeState == RouteState.LOST) { return; } checkApproachMilestone(Milestone.TWO_MILE, METERS_IN_ONE_MILE * 2); checkApproachMilestone(Milestone.ONE_MILE, METERS_IN_ONE_MILE); checkApproachMilestone(Milestone.QUARTER_MILE, METERS_IN_ONE_MILE / 4); if (routeState == RouteState.PRE_INSTRUCTION && route.getDistanceToNextInstruction() < ALERT_RADIUS && route.getNextInstructionIndex() != null) { final int nextIndex = route.getNextInstructionIndex(); listener.onApproachInstruction(nextIndex); routeState = RouteState.INSTRUCTION; lastMilestoneUpdate = null; } final Instruction nextInstruction = route.getNextInstruction(); if (instructions != null && !currentInstruction.equals(nextInstruction)) { routeState = RouteState.PRE_INSTRUCTION; int nextIndex = instructions.indexOf(currentInstruction); listener.onInstructionComplete(nextIndex); } currentInstruction = route.getNextInstruction(); }
RouteEngine { public void onLocationChanged(final ValhallaLocation location) { if (routeState == RouteState.COMPLETE) { return; } this.location = location; snapLocation(); if (routeState == RouteState.COMPLETE) { listener.onUpdateDistance(0, 0); } else { listener.onUpdateDistance(route.getDistanceToNextInstruction(), route.getRemainingDistanceToDestination()); } if (routeState == RouteState.LOST) { return; } checkApproachMilestone(Milestone.TWO_MILE, METERS_IN_ONE_MILE * 2); checkApproachMilestone(Milestone.ONE_MILE, METERS_IN_ONE_MILE); checkApproachMilestone(Milestone.QUARTER_MILE, METERS_IN_ONE_MILE / 4); if (routeState == RouteState.PRE_INSTRUCTION && route.getDistanceToNextInstruction() < ALERT_RADIUS && route.getNextInstructionIndex() != null) { final int nextIndex = route.getNextInstructionIndex(); listener.onApproachInstruction(nextIndex); routeState = RouteState.INSTRUCTION; lastMilestoneUpdate = null; } final Instruction nextInstruction = route.getNextInstruction(); if (instructions != null && !currentInstruction.equals(nextInstruction)) { routeState = RouteState.PRE_INSTRUCTION; int nextIndex = instructions.indexOf(currentInstruction); listener.onInstructionComplete(nextIndex); } currentInstruction = route.getNextInstruction(); } }
RouteEngine { public void onLocationChanged(final ValhallaLocation location) { if (routeState == RouteState.COMPLETE) { return; } this.location = location; snapLocation(); if (routeState == RouteState.COMPLETE) { listener.onUpdateDistance(0, 0); } else { listener.onUpdateDistance(route.getDistanceToNextInstruction(), route.getRemainingDistanceToDestination()); } if (routeState == RouteState.LOST) { return; } checkApproachMilestone(Milestone.TWO_MILE, METERS_IN_ONE_MILE * 2); checkApproachMilestone(Milestone.ONE_MILE, METERS_IN_ONE_MILE); checkApproachMilestone(Milestone.QUARTER_MILE, METERS_IN_ONE_MILE / 4); if (routeState == RouteState.PRE_INSTRUCTION && route.getDistanceToNextInstruction() < ALERT_RADIUS && route.getNextInstructionIndex() != null) { final int nextIndex = route.getNextInstructionIndex(); listener.onApproachInstruction(nextIndex); routeState = RouteState.INSTRUCTION; lastMilestoneUpdate = null; } final Instruction nextInstruction = route.getNextInstruction(); if (instructions != null && !currentInstruction.equals(nextInstruction)) { routeState = RouteState.PRE_INSTRUCTION; int nextIndex = instructions.indexOf(currentInstruction); listener.onInstructionComplete(nextIndex); } currentInstruction = route.getNextInstruction(); }  }
RouteEngine { public void onLocationChanged(final ValhallaLocation location) { if (routeState == RouteState.COMPLETE) { return; } this.location = location; snapLocation(); if (routeState == RouteState.COMPLETE) { listener.onUpdateDistance(0, 0); } else { listener.onUpdateDistance(route.getDistanceToNextInstruction(), route.getRemainingDistanceToDestination()); } if (routeState == RouteState.LOST) { return; } checkApproachMilestone(Milestone.TWO_MILE, METERS_IN_ONE_MILE * 2); checkApproachMilestone(Milestone.ONE_MILE, METERS_IN_ONE_MILE); checkApproachMilestone(Milestone.QUARTER_MILE, METERS_IN_ONE_MILE / 4); if (routeState == RouteState.PRE_INSTRUCTION && route.getDistanceToNextInstruction() < ALERT_RADIUS && route.getNextInstructionIndex() != null) { final int nextIndex = route.getNextInstructionIndex(); listener.onApproachInstruction(nextIndex); routeState = RouteState.INSTRUCTION; lastMilestoneUpdate = null; } final Instruction nextInstruction = route.getNextInstruction(); if (instructions != null && !currentInstruction.equals(nextInstruction)) { routeState = RouteState.PRE_INSTRUCTION; int nextIndex = instructions.indexOf(currentInstruction); listener.onInstructionComplete(nextIndex); } currentInstruction = route.getNextInstruction(); }  void onLocationChanged(final ValhallaLocation location); void setRoute(Route route); Route getRoute(); void setListener(RouteListener listener); }
RouteEngine { public void onLocationChanged(final ValhallaLocation location) { if (routeState == RouteState.COMPLETE) { return; } this.location = location; snapLocation(); if (routeState == RouteState.COMPLETE) { listener.onUpdateDistance(0, 0); } else { listener.onUpdateDistance(route.getDistanceToNextInstruction(), route.getRemainingDistanceToDestination()); } if (routeState == RouteState.LOST) { return; } checkApproachMilestone(Milestone.TWO_MILE, METERS_IN_ONE_MILE * 2); checkApproachMilestone(Milestone.ONE_MILE, METERS_IN_ONE_MILE); checkApproachMilestone(Milestone.QUARTER_MILE, METERS_IN_ONE_MILE / 4); if (routeState == RouteState.PRE_INSTRUCTION && route.getDistanceToNextInstruction() < ALERT_RADIUS && route.getNextInstructionIndex() != null) { final int nextIndex = route.getNextInstructionIndex(); listener.onApproachInstruction(nextIndex); routeState = RouteState.INSTRUCTION; lastMilestoneUpdate = null; } final Instruction nextInstruction = route.getNextInstruction(); if (instructions != null && !currentInstruction.equals(nextInstruction)) { routeState = RouteState.PRE_INSTRUCTION; int nextIndex = instructions.indexOf(currentInstruction); listener.onInstructionComplete(nextIndex); } currentInstruction = route.getNextInstruction(); }  void onLocationChanged(final ValhallaLocation location); void setRoute(Route route); Route getRoute(); void setListener(RouteListener listener); static final int APPROACH_RADIUS; static final int ALERT_RADIUS; static final int DESTINATION_RADIUS; }