Search in sources :

Example 6 with InterstitialController

use of org.prebid.mobile.rendering.bidding.display.InterstitialController in project prebid-mobile-android by prebid.

the class RewardedAdUnitTest method showWhenAuctionWinnerIsPrebid_ShowPrebid.

@Test
public void showWhenAuctionWinnerIsPrebid_ShowPrebid() {
    final InterstitialController mockInterstitialController = mock(InterstitialController.class);
    changeInterstitialState(READY_TO_DISPLAY_PREBID);
    WhiteBox.setInternalState(mRewardedAdUnit, "mInterstitialController", mockInterstitialController);
    mRewardedAdUnit.show();
    verify(mockInterstitialController, times(1)).show();
}
Also used : InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) Test(org.junit.Test)

Example 7 with InterstitialController

use of org.prebid.mobile.rendering.bidding.display.InterstitialController in project prebid-mobile-android by prebid.

the class PrebidInterstitialAdapter method requestInterstitialAd.

@Override
public void requestInterstitialAd(@NonNull Context context, @NonNull CustomEventInterstitialListener adMobListener, @Nullable String serverParameter, @NonNull MediationAdRequest mediationAdRequest, @Nullable Bundle extras) {
    if (extras == null) {
        String error = "Extras are empty! Check if you add custom event extras bundle to  " + TAG;
        Log.e(TAG, error);
        adMobListener.onAdFailedToLoad(new AdError(1001, error, "prebid"));
        return;
    }
    String responseId = extras.getString(EXTRA_RESPONSE_ID);
    if (responseId == null) {
        String error = "Response id is null";
        adMobListener.onAdFailedToLoad(new AdError(1002, error, "prebid"));
        return;
    }
    HashMap<String, String> prebidParameters = BidResponseCache.getInstance().getKeywords(responseId);
    if (!ParametersMatcher.doParametersMatch(serverParameter, prebidParameters)) {
        String error = "Parameters are different";
        adMobListener.onAdFailedToLoad(new AdError(1003, error, "prebid"));
        return;
    }
    LogUtil.v(TAG, "Parameters are matched! (" + serverParameter + ")");
    try {
        InterstitialControllerListener listener = getListener(adMobListener);
        interstitialController = new InterstitialController(context, listener);
        interstitialController.loadAd(responseId, false);
    } catch (AdException e) {
        String error = "Exception in Prebid interstitial controller (" + e.getMessage() + ")";
        Log.e(TAG, error);
        adMobListener.onAdFailedToLoad(new AdError(1004, error, "prebid"));
    }
}
Also used : InterstitialControllerListener(org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener) InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) AdError(com.google.android.gms.ads.AdError) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 8 with InterstitialController

use of org.prebid.mobile.rendering.bidding.display.InterstitialController in project prebid-mobile-android by prebid.

the class PrebidRewardedAdapter method loadRewardedAd.

@Override
public void loadRewardedAd(@NonNull MediationRewardedAdConfiguration adConfiguration, @NonNull MediationAdLoadCallback<MediationRewardedAd, MediationRewardedAdCallback> callback) {
    Bundle serverParameters = adConfiguration.getServerParameters();
    String adMobParameters = serverParameters.getString("parameter");
    String adMobClassName = serverParameters.getString("class_name");
    if (!adMobClassName.equals(CLASS_NAME)) {
        String error = "Class name is different";
        callback.onFailure(new AdError(1001, error, "prebid"));
        return;
    }
    String responseId = adConfiguration.getMediationExtras().getString(EXTRA_RESPONSE_ID);
    if (responseId == null) {
        String error = "Empty response id";
        callback.onFailure(new AdError(1002, error, "prebid"));
        return;
    }
    HashMap<String, String> prebidParameters = BidResponseCache.getInstance().getKeywords(responseId);
    if (prebidParameters == null) {
        String error = "Prebid keywords are empty";
        callback.onFailure(new AdError(1003, error, "prebid"));
        return;
    }
    if (!ParametersMatcher.doParametersMatch(adMobParameters, prebidParameters)) {
        String error = "Parameters are different";
        callback.onFailure(new AdError(1004, error, "prebid"));
        return;
    }
    try {
        InterstitialControllerListener listener = getListener(callback);
        interstitialController = new InterstitialController(adConfiguration.getContext(), listener);
        interstitialController.loadAd(responseId, true);
    } catch (AdException e) {
        String error = "Exception in Prebid interstitial controller (" + e.getMessage() + ")";
        Log.e(TAG, error);
        callback.onFailure(new AdError(1005, error, "prebid"));
    }
}
Also used : InterstitialControllerListener(org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener) Bundle(android.os.Bundle) InterstitialController(org.prebid.mobile.rendering.bidding.display.InterstitialController) AdError(com.google.android.gms.ads.AdError) AdException(org.prebid.mobile.rendering.errors.AdException)

Aggregations

InterstitialController (org.prebid.mobile.rendering.bidding.display.InterstitialController)8 AdException (org.prebid.mobile.rendering.errors.AdException)6 Test (org.junit.Test)4 AdError (com.google.android.gms.ads.AdError)2 Bid (org.prebid.mobile.rendering.bidding.data.bid.Bid)2 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)2 InterstitialControllerListener (org.prebid.mobile.rendering.bidding.interfaces.InterstitialControllerListener)2 Bundle (android.os.Bundle)1 InterstitialEventListener (org.prebid.mobile.rendering.bidding.listeners.InterstitialEventListener)1 RewardedVideoEventListener (org.prebid.mobile.rendering.bidding.listeners.RewardedVideoEventListener)1