use of org.prebid.mobile.rendering.bidding.listeners.DisplayViewListener in project prebid-mobile-android by prebid.
the class PrebidBannerAdapter method getListener.
@NonNull
private DisplayViewListener getListener(CustomEventBannerListener adMobListener) {
return new DisplayViewListener() {
@Override
public void onAdLoaded() {
adMobListener.onAdLoaded(adView);
}
@Override
public void onAdDisplayed() {
}
@Override
public void onAdFailed(AdException exception) {
String message = exception.getMessage();
if (message == null)
message = "Failed to load DisplayView ad";
adMobListener.onAdFailedToLoad(new AdError(1010, message, "prebid"));
}
@Override
public void onAdClicked() {
adMobListener.onAdClicked();
adMobListener.onAdOpened();
}
@Override
public void onAdClosed() {
adMobListener.onAdClosed();
}
};
}
use of org.prebid.mobile.rendering.bidding.listeners.DisplayViewListener in project prebid-mobile-android by prebid.
the class PrebidBannerAdapter method requestBannerAd.
@Override
public void requestBannerAd(@NonNull Context context, @NonNull CustomEventBannerListener adMobListener, @Nullable String serverParameter, @NonNull AdSize adSize, @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 + ")");
BidResponse response = BidResponseCache.getInstance().popBidResponse(responseId);
if (response == null) {
String error = "There's no response for the response id: " + responseId;
adMobListener.onAdFailedToLoad(new AdError(1004, error, "prebid"));
return;
}
AdConfiguration adConfiguration = new AdConfiguration();
adConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
DisplayViewListener listener = getListener(adMobListener);
adView = new DisplayView(context, listener, adConfiguration, response);
}
Aggregations