private static List generateTripUpdateSequence()

in car_app_library/navigation/common/src/main/java/androidx/car/app/sample/navigation/common/model/DemoScripts.java [389:457]


    private static List<Instruction> generateTripUpdateSequence(
            int count,
            int startDestinationDistanceRemaining,
            int startStepDistanceRemaining,
            DateTimeWithZone arrivalTimeAtDestination,
            String currentRoad,
            @Nullable CarIcon junctionImage,
            boolean showLanes,
            String nextInstruction,
            int speed,
            int notificationIcon) {
        List<Instruction> sequence = new ArrayList<>(count);
        int destinationDistanceRemaining = startDestinationDistanceRemaining;
        int stepDistanceRemaining = startStepDistanceRemaining;
        int distanceIncrement = startStepDistanceRemaining / count;
        boolean notify = true;

        for (int i = 0; i < count; i++) {
            Distance remainingDistance =
                    Distance.create(stepDistanceRemaining, Distance.UNIT_METERS);
            TravelEstimate destinationTravelEstimate =
                    new TravelEstimate.Builder(
                            Distance.create(
                                    destinationDistanceRemaining, Distance.UNIT_METERS),
                            arrivalTimeAtDestination)
                            .setRemainingTimeSeconds(destinationDistanceRemaining / speed)
                            .setRemainingTimeColor(CarColor.YELLOW)
                            .setRemainingDistanceColor(CarColor.GREEN)
                            .build();
            TravelEstimate stepTravelEstimate =
                    new TravelEstimate.Builder(
                            remainingDistance,
                            getCurrentDateTimeZoneWithOffset(distanceIncrement))
                            .setRemainingTimeSeconds(/* remainingTimeSeconds= */ distanceIncrement)
                            .build();
            String notificationTitle = String.format("%dm", stepDistanceRemaining);
            Instruction.Builder instruction =
                    Instruction.builder(
                            Instruction.Type.SET_TRIP_POSITION_NAVIGATION,
                            TimeUnit.SECONDS.toMillis(distanceIncrement / speed))
                            .setStepRemainingDistance(remainingDistance)
                            .setStepTravelEstimate(stepTravelEstimate)
                            .setDestinationTravelEstimate(destinationTravelEstimate)
                            .setRoad(currentRoad)
                            .setNotification(
                                    notify, notificationTitle, nextInstruction, notificationIcon);
            // Don't show lanes in the first and last part of the maneuver. In the middle part of
            // the
            // maneuver use the passed parameter to determine if lanes should be shown.
            if (i == 0) {
                instruction.setShouldShowLanes(false).setShouldShowNextStep(true);
            } else if (i == 1) {
                instruction.setShouldShowLanes(showLanes).setShouldShowNextStep(true);
            } else if (i == 2) {
                instruction.setShouldShowLanes(showLanes).setShouldShowNextStep(false);
            } else {
                instruction
                        .setShouldShowLanes(false)
                        .setShouldShowNextStep(false)
                        .setJunctionImage(junctionImage);
            }
            sequence.add(instruction.build());

            destinationDistanceRemaining -= distanceIncrement;
            stepDistanceRemaining -= distanceIncrement;
            notify = false;
        }
        return sequence;
    }