Search in sources :

Example 1 with AdView

use of com.facebook.ads.AdView in project react-native-fbads by callstack.

the class BannerView method createAdViewIfCan.

private void createAdViewIfCan() {
    if (myAdView == null && mPlacementId != null && mSize != null) {
        myAdView = new AdView(this.getContext(), mPlacementId, mSize);
        myAdView.setAdListener(this);
        myAdView.loadAd();
    }
}
Also used : AdView(com.facebook.ads.AdView)

Example 2 with AdView

use of com.facebook.ads.AdView in project mopub-android-mediation by mopub.

the class FacebookBanner method loadBanner.

/**
 * CustomEventBanner implementation
 */
@Override
protected void loadBanner(final Context context, final CustomEventBannerListener customEventBannerListener, final Map<String, Object> localExtras, final Map<String, String> serverExtras) {
    mBannerListener = customEventBannerListener;
    final String placementId;
    if (serverExtrasAreValid(serverExtras)) {
        placementId = serverExtras.get(PLACEMENT_ID_KEY);
    } else {
        mBannerListener.onBannerFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
        return;
    }
    int width;
    int height;
    if (localExtrasAreValid(localExtras)) {
        width = (Integer) localExtras.get(DataKeys.AD_WIDTH);
        height = (Integer) localExtras.get(DataKeys.AD_HEIGHT);
    } else {
        mBannerListener.onBannerFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
        return;
    }
    AdSize adSize = calculateAdSize(width, height);
    if (adSize == null) {
        mBannerListener.onBannerFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
        return;
    }
    AdSettings.setMediationService("MOPUB_" + MoPub.SDK_VERSION);
    mFacebookBanner = new AdView(context, placementId, adSize);
    mFacebookBanner.setAdListener(this);
    mFacebookBanner.disableAutoRefresh();
    mFacebookBanner.loadAd();
}
Also used : AdSize(com.facebook.ads.AdSize) AdView(com.facebook.ads.AdView)

Aggregations

AdView (com.facebook.ads.AdView)2 AdSize (com.facebook.ads.AdSize)1