Skip to content

Commit b626b27

Browse files
author
Devota Aabel
committed
Added nav-native etas
1 parent 69d047a commit b626b27

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/summary/SummaryModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public class SummaryModel {
2222
public SummaryModel(Context context, DistanceFormatter distanceFormatter, RouteProgress progress,
2323
@NavigationTimeFormat.Type int timeFormatType) {
2424
distanceRemaining = distanceFormatter.formatDistance(progress.distanceRemaining()).toString();
25-
timeRemaining = formatTimeRemaining(context, progress.durationRemaining());
25+
timeRemaining = formatTimeRemaining(context, progress.legDurationRemaining());
2626
Calendar time = Calendar.getInstance();
2727
boolean isTwentyFourHourFormat = DateFormat.is24HourFormat(context);
28-
arrivalTime = formatTime(time, progress.durationRemaining(), timeFormatType, isTwentyFourHourFormat);
28+
arrivalTime = formatTime(time, progress.legDurationRemaining(), timeFormatType, isTwentyFourHourFormat);
2929
}
3030

3131
String getDistanceRemaining() {

libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationNotificationProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ void updateNavigationNotification(RouteProgress routeProgress) {
2525
}
2626

2727
void shutdown(Context context) {
28-
navigationNotification.onNavigationStopped(context);
28+
if (navigationNotification != null) {
29+
navigationNotification.onNavigationStopped(context);
30+
}
2931
navigationNotification = null;
3032
shouldUpdate = false;
3133
}

libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationRouteProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.mapbox.api.directions.v5.models.StepIntersection;
1010
import com.mapbox.geojson.Point;
1111
import com.mapbox.navigator.NavigationStatus;
12+
import com.mapbox.navigator.RouteState;
1213
import com.mapbox.navigator.VoiceInstruction;
1314
import com.mapbox.services.android.navigation.v5.routeprogress.CurrentLegAnnotation;
1415
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress;
@@ -69,6 +70,9 @@ private RouteProgress buildRouteProgressFrom(NavigationStatus status) {
6970
double routeDistanceRemaining = routeDistanceRemaining(legDistanceRemaining, legIndex, route);
7071
double stepDistanceRemaining = status.getRemainingStepDistance();
7172
double stepDistanceTraveled = currentStep.distance() - stepDistanceRemaining;
73+
double remainingLegDuration = status.getRouteState() == RouteState.TRACKING
74+
? status.getRemainingLegDuration() / 1000 : route.duration();
75+
7276
currentLegAnnotation = createCurrentAnnotation(currentLegAnnotation, currentLeg, legDistanceRemaining);
7377
StepIntersection currentIntersection = findCurrentIntersection(
7478
currentIntersections, currentIntersectionDistances, stepDistanceTraveled
@@ -81,6 +85,7 @@ private RouteProgress buildRouteProgressFrom(NavigationStatus status) {
8185
.stepDistanceRemaining(stepDistanceRemaining)
8286
.legDistanceRemaining(legDistanceRemaining)
8387
.distanceRemaining(routeDistanceRemaining)
88+
.legDurationRemaining(remainingLegDuration)
8489
.directionsRoute(route)
8590
.currentStepPoints(currentStepPoints)
8691
.upcomingStepPoints(upcomingStepPoints)

libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/routeprogress/RouteProgress.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public double durationRemaining() {
8787
return (1 - fractionTraveled()) * directionsRoute().duration();
8888
}
8989

90+
public abstract double legDurationRemaining();
91+
9092
/**
9193
* Get the fraction traveled along the current route, this is a float value between 0 and 1 and
9294
* isn't guaranteed to reach 1 before the user reaches the end of the route.
@@ -221,6 +223,10 @@ public abstract static class Builder {
221223

222224
public abstract Builder distanceRemaining(double distanceRemaining);
223225

226+
public abstract Builder legDurationRemaining(double durationRemaining);
227+
228+
abstract double legDurationRemaining();
229+
224230
public abstract Builder intersections(List<StepIntersection> intersections);
225231

226232
abstract List<StepIntersection> intersections();

0 commit comments

Comments
 (0)