Search in sources :

Example 1 with AdSize

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

the class BannerViewManager method setSize.

@ReactProp(name = "size")
public void setSize(BannerView view, int size) {
    AdSize adSize = null;
    switch(size) {
        case 90:
            adSize = AdSize.BANNER_HEIGHT_90;
            break;
        case 250:
            adSize = AdSize.RECTANGLE_HEIGHT_250;
        case 50:
        default:
            adSize = AdSize.BANNER_HEIGHT_50;
    }
    view.setSize(adSize);
}
Also used : AdSize(com.facebook.ads.AdSize) ReactProp(com.facebook.react.uimanager.annotations.ReactProp)

Example 2 with AdSize

use of com.facebook.ads.AdSize 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

AdSize (com.facebook.ads.AdSize)2 AdView (com.facebook.ads.AdView)1 ReactProp (com.facebook.react.uimanager.annotations.ReactProp)1