NativeAdPreloader

public interface NativeAdPreloader


Summary

Nested types

public static class NativeAdPreloader.Companion extends AdPreloader

Public methods

default static boolean
destroy(@NonNull String preloadId)

Permanently stops preloading for the given preloadId and destroys all associated preloaded ads.

default static PreloadConfiguration

Returns the PreloadConfiguration associated with this preloadId and ad format, or null if one does not exist.

default static @NonNull Map<@NonNull String, @NonNull PreloadConfiguration>

Returns a map of all PreloadConfigurations associated with this format, keyed by preload ID.

default static int

Returns the number of preloaded ads available for the given preloadId.

default static boolean

Returns true if at least one ad is available for the given preloadId.

default static int

This method is deprecated. Use {@link #getNumAdsAvailable} instead

default static NativeAdLoadResult.NativeAdLoadSuccessResult
pollAd(@NonNull String preloadId)

Returns an ad preloaded from start or null if no ad is available.

default static boolean
start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration
)

Starts preloading without a callback.

default static boolean
start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration,
    PreloadCallback preloadCallback
)

Starts preloading ads for the given PreloadConfiguration + preloadId and returns true.

Public methods

destroy

default static boolean destroy(@NonNull String preloadId)

Permanently stops preloading for the given preloadId and destroys all associated preloaded ads.

Returns true if preloading was stopped, false if there is no active preload for preloadId.

getConfiguration

default static PreloadConfiguration getConfiguration(@NonNull String preloadId)

Returns the PreloadConfiguration associated with this preloadId and ad format, or null if one does not exist.

getConfigurations

default static @NonNull Map<@NonNull String, @NonNull PreloadConfigurationgetConfigurations()

Returns a map of all PreloadConfigurations associated with this format, keyed by preload ID.

getNumAdsAvailable

default static int getNumAdsAvailable(@NonNull String preloadId)

Returns the number of preloaded ads available for the given preloadId.

isAdAvailable

default static boolean isAdAvailable(@NonNull String preloadId)

Returns true if at least one ad is available for the given preloadId.

numAdsAvailable

default static int numAdsAvailable(@NonNull String preloadId)

Returns the number of preloaded ads available for the given preloadId.

pollAd

default static NativeAdLoadResult.NativeAdLoadSuccessResult pollAd(@NonNull String preloadId)

Returns an ad preloaded from start or null if no ad is available.

Note that this may be any of the ads preloaded for preloadId. The order returned is not guaranteed to match the order of PreloadCallback.onAdPreloaded events.

start

default static boolean start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration
)

Starts preloading without a callback.

start

default static boolean start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration,
    PreloadCallback preloadCallback
)

Starts preloading ads for the given PreloadConfiguration + preloadId and returns true.

The SDK will continue to preload ads until the number the number of ads specified by PreloadConfiguration.bufferSize is reached, attempting to keep the buffer full throughout the session.

Each ad request the SDK attempts results in either a PreloadCallback.onAdPreloaded or PreloadCallback.onAdFailedToPreload callback. The SDK includes retry logic for requests that fail.

If a PreloadConfiguration was already started with preloadId, this method becomes a no-op and returns false.

Parameters
@NonNull String preloadId

A string identifier for this PreloadConfiguration + ad format. Use this identifier for all future calls to control preloading for this PreloadConfiguration, like pollAd or destroy.

@NonNull PreloadConfiguration preloadConfiguration

The configuration to preload ads for.

PreloadCallback preloadCallback

A callback to be invoked when ad availability changes for the given PreloadConfiguration.

Returns
boolean

True if preloading started, false otherwise.