Search in sources :

Example 1 with MediationAdLoadCallback

use of com.google.android.gms.ads.mediation.MediationAdLoadCallback in project prebid-mobile-android by prebid.

the class PrebidRewardedAdapter method getListener.

private InterstitialControllerListener getListener(MediationAdLoadCallback<MediationRewardedAd, MediationRewardedAdCallback> adMobCallback) {
    return new InterstitialControllerListener() {

        @Override
        public void onInterstitialReadyForDisplay() {
            rewardedAdCallback = adMobCallback.onSuccess(context -> {
                interstitialController.show();
            });
        }

        @Override
        public void onInterstitialDisplayed() {
            rewardedAdCallback.onAdOpened();
            rewardedAdCallback.onVideoStart();
            rewardedAdCallback.reportAdImpression();
        }

        @Override
        public void onInterstitialClicked() {
            rewardedAdCallback.reportAdClicked();
        }

        @Override
        public void onInterstitialFailedToLoad(AdException exception) {
            String errorMessage = exception.getMessage() != null ? exception.getMessage() : "Failed to load ad";
            AdError adError = new AdError(1006, errorMessage, "prebid");
            adMobCallback.onFailure(adError);
            if (rewardedAdCallback != null) {
                rewardedAdCallback.onAdFailedToShow(adError);
            }
        }

        @Override
        public void onInterstitialClosed() {
            rewardedAdCallback.onVideoComplete();
            rewardedAdCallback.onAdClosed();
        }
    };
}
Also used : InterstitialControllerListener(org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener) RewardItem(com.google.android.gms.ads.rewarded.RewardItem) InterstitialControllerListener(org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener) Bundle(android.os.Bundle) AdException(org.prebid.mobile.rendering.errors.AdException) NonNull(androidx.annotation.NonNull) MediationRewardedAd(com.google.android.gms.ads.mediation.MediationRewardedAd) HashMap(java.util.HashMap) AdError(com.google.android.gms.ads.AdError) InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) Keep(androidx.annotation.Keep) BidResponseCache(org.prebid.mobile.rendering.bidding.display.BidResponseCache) MediationRewardedAdConfiguration(com.google.android.gms.ads.mediation.MediationRewardedAdConfiguration) MediationRewardedAdCallback(com.google.android.gms.ads.mediation.MediationRewardedAdCallback) MediationAdLoadCallback(com.google.android.gms.ads.mediation.MediationAdLoadCallback) Log(android.util.Log) AdError(com.google.android.gms.ads.AdError) AdException(org.prebid.mobile.rendering.errors.AdException)

Aggregations

Bundle (android.os.Bundle)1 Log (android.util.Log)1 Keep (androidx.annotation.Keep)1 NonNull (androidx.annotation.NonNull)1 AdError (com.google.android.gms.ads.AdError)1 MediationAdLoadCallback (com.google.android.gms.ads.mediation.MediationAdLoadCallback)1 MediationRewardedAd (com.google.android.gms.ads.mediation.MediationRewardedAd)1 MediationRewardedAdCallback (com.google.android.gms.ads.mediation.MediationRewardedAdCallback)1 MediationRewardedAdConfiguration (com.google.android.gms.ads.mediation.MediationRewardedAdConfiguration)1 RewardItem (com.google.android.gms.ads.rewarded.RewardItem)1 HashMap (java.util.HashMap)1 BidResponseCache (org.prebid.mobile.rendering.bidding.display.BidResponseCache)1 InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)1 InterstitialControllerListener (org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener)1 AdException (org.prebid.mobile.rendering.errors.AdException)1