Search in sources :

Example 1 with BannerInstructions

use of com.mapbox.api.directions.v5.models.BannerInstructions in project mapbox-navigation-android by mapbox.

the class InstructionLoader method prefetchImageCache.

/**
 * Will pre-fetch images for a given {@link LegStep}.
 * <p>
 * If loaded successfully, this will allow the images to be displayed
 * without delay in the {@link InstructionView}.
 *
 * @param step providing the image Urls
 */
public void prefetchImageCache(LegStep step) {
    if (step == null || step.bannerInstructions() == null || step.bannerInstructions().isEmpty()) {
        return;
    }
    checkIsInitialized();
    List<BannerInstructions> bannerInstructionList = new ArrayList<>(step.bannerInstructions());
    for (BannerInstructions instructions : bannerInstructionList) {
        if (hasComponents(instructions.primary())) {
            fetchImageBaseUrls(instructions.primary());
        }
        if (hasComponents(instructions.secondary())) {
            fetchImageBaseUrls(instructions.secondary());
        }
    }
}
Also used : BannerInstructions(com.mapbox.api.directions.v5.models.BannerInstructions) ArrayList(java.util.ArrayList)

Example 2 with BannerInstructions

use of com.mapbox.api.directions.v5.models.BannerInstructions in project mapbox-navigation-android by mapbox.

the class BannerInstructionMilestone method isOccurring.

@Override
public boolean isOccurring(RouteProgress previousRouteProgress, RouteProgress routeProgress) {
    if (newRoute(routeProgress)) {
        clearInstructionList();
    }
    if (shouldAddInstructions(routeProgress)) {
        stepBannerInstructions = routeProgress.currentLegProgress().currentStep().bannerInstructions();
    }
    for (BannerInstructions instructions : stepBannerInstructions) {
        if (shouldBeShown(routeProgress, instructions)) {
            this.instructions = instructions;
            stepBannerInstructions.remove(instructions);
            return true;
        }
    }
    return false;
}
Also used : BannerInstructions(com.mapbox.api.directions.v5.models.BannerInstructions)

Aggregations

BannerInstructions (com.mapbox.api.directions.v5.models.BannerInstructions)2 ArrayList (java.util.ArrayList)1