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);
}
Aggregations