use of org.prebid.mobile.rendering.bidding.display.DisplayView 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);
}
use of org.prebid.mobile.rendering.bidding.display.DisplayView in project prebid-mobile-android by prebid.
the class PrebidBannerAdapter method initDisplayView.
private void initDisplayView(Context context, String responseId) {
try {
AdConfiguration adUnitConfiguration = new AdConfiguration();
adUnitConfiguration.setAdUnitIdentifierType(AdConfiguration.AdUnitIdentifierType.BANNER);
mDisplayView = new DisplayView(context, mDisplayViewListener, adUnitConfiguration, responseId);
} catch (AdException e) {
MoPubLog.log(MoPubLog.AdapterLogEvent.LOAD_FAILED, TAG);
mLoadListener.onAdLoadFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
}
}
use of org.prebid.mobile.rendering.bidding.display.DisplayView in project prebid-mobile-android by prebid.
the class BannerView method displayPrebidView.
private void displayPrebidView() {
if (indexOfChild(mDisplayView) != -1) {
mDisplayView.destroy();
mDisplayView = null;
}
removeAllViews();
final Pair<Integer, Integer> sizePair = mBidResponse.getWinningBidWidthHeightPairDips(getContext());
mDisplayView = new DisplayView(getContext(), mDisplayViewListener, mAdUnitConfig, mBidResponse);
addView(mDisplayView, sizePair.first, sizePair.second);
}
Aggregations