Search in sources :

Example 1 with OnAdManagerAdViewLoadedListener

use of com.google.android.gms.ads.formats.OnAdManagerAdViewLoadedListener in project prebid-mobile-android by prebid.

the class XandrNativeInAppGAMDemoActivity method loadDfp.

private void loadDfp(AdManagerAdRequest adManagerAdRequest) {
    adLoader = new AdLoader.Builder(this, DFP_NATIVE_NATIVE_ADUNIT_ID_APPNEXUS).forAdManagerAdView(new OnAdManagerAdViewLoadedListener() {

        @Override
        public void onAdManagerAdViewLoaded(AdManagerAdView adManagerAdView) {
            adView = adManagerAdView;
            ((FrameLayout) findViewById(R.id.adFrame)).addView(adManagerAdView);
        }
    }, AdSize.BANNER).forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {

        @Override
        public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
            LogUtil.d("Prebid", "native loaded");
            XandrNativeInAppGAMDemoActivity.this.unifiedNativeAd = unifiedNativeAd;
        }
    }).forCustomTemplateAd("11963183", new NativeCustomTemplateAd.OnCustomTemplateAdLoadedListener() {

        @Override
        public void onCustomTemplateAdLoaded(NativeCustomTemplateAd nativeCustomTemplateAd) {
            LogUtil.d("Prebid", "custom ad loaded");
            AdViewUtils.findNative(nativeCustomTemplateAd, new PrebidNativeAdListener() {

                @Override
                public void onPrebidNativeLoaded(PrebidNativeAd ad) {
                    inflatePrebidNativeAd(ad);
                }

                @Override
                public void onPrebidNativeNotFound() {
                    LogUtil.d("Prebid", "onPrebidNativeNotFound");
                // inflate nativeCustomTemplateAd
                }

                @Override
                public void onPrebidNativeNotValid() {
                    LogUtil.d("Prebid", "onPrebidNativeNotFound");
                // show your own content
                }
            });
        }
    }, new NativeCustomTemplateAd.OnCustomClickListener() {

        @Override
        public void onCustomClick(NativeCustomTemplateAd nativeCustomTemplateAd, String s) {
        }
    }).withAdListener(new AdListener() {

        @Override
        public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
            super.onAdFailedToLoad(loadAdError);
            Toast.makeText(XandrNativeInAppGAMDemoActivity.this, "DFP onAdFailedToLoad", Toast.LENGTH_SHORT).show();
        }
    }).build();
    adLoader.loadAd(adManagerAdRequest);
}
Also used : LoadAdError(com.google.android.gms.ads.LoadAdError) AdListener(com.google.android.gms.ads.AdListener) PrebidNativeAdListener(org.prebid.mobile.PrebidNativeAdListener) NativeCustomTemplateAd(com.google.android.gms.ads.formats.NativeCustomTemplateAd) AdManagerAdView(com.google.android.gms.ads.admanager.AdManagerAdView) FrameLayout(android.widget.FrameLayout) PrebidNativeAdListener(org.prebid.mobile.PrebidNativeAdListener) OnAdManagerAdViewLoadedListener(com.google.android.gms.ads.formats.OnAdManagerAdViewLoadedListener) PrebidNativeAd(org.prebid.mobile.PrebidNativeAd) UnifiedNativeAd(com.google.android.gms.ads.formats.UnifiedNativeAd)

Aggregations

FrameLayout (android.widget.FrameLayout)1 AdListener (com.google.android.gms.ads.AdListener)1 LoadAdError (com.google.android.gms.ads.LoadAdError)1 AdManagerAdView (com.google.android.gms.ads.admanager.AdManagerAdView)1 NativeCustomTemplateAd (com.google.android.gms.ads.formats.NativeCustomTemplateAd)1 OnAdManagerAdViewLoadedListener (com.google.android.gms.ads.formats.OnAdManagerAdViewLoadedListener)1 UnifiedNativeAd (com.google.android.gms.ads.formats.UnifiedNativeAd)1 PrebidNativeAd (org.prebid.mobile.PrebidNativeAd)1 PrebidNativeAdListener (org.prebid.mobile.PrebidNativeAdListener)1