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();
}
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"));
}
}
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"));
}
}
Aggregations