Search in sources :

Example 1 with DisplayView

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);
}
Also used : DisplayViewListener(org.prebid.mobile.rendering.bidding.listeners.DisplayViewListener) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) AdError(com.google.android.gms.ads.AdError) DisplayView(org.prebid.mobile.rendering.bidding.display.DisplayView)

Example 2 with DisplayView

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);
    }
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) DisplayView(org.prebid.mobile.rendering.bidding.display.DisplayView) AdException(org.prebid.mobile.rendering.errors.AdException)

Example 3 with DisplayView

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);
}
Also used : DisplayView(org.prebid.mobile.rendering.bidding.display.DisplayView)

Aggregations

DisplayView (org.prebid.mobile.rendering.bidding.display.DisplayView)3 AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)2 AdError (com.google.android.gms.ads.AdError)1 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)1 DisplayViewListener (org.prebid.mobile.rendering.bidding.listeners.DisplayViewListener)1 AdException (org.prebid.mobile.rendering.errors.AdException)1