use of com.google.android.gms.ads.formats.NativeCustomTemplateAd in project prebid-mobile-android by prebid.
the class UtilTest method testFindNativeLoadedDFP.
@Test
public void testFindNativeLoadedDFP() {
String mockedResponse = MockPrebidServerResponses.validResponsePrebidNativeNativeBid();
String cacheId = CacheManager.save(mockedResponse);
NativeCustomTemplateAd nativeCustomTemplateAd = Mockito.mock(NativeCustomTemplateAd.class);
Mockito.when(nativeCustomTemplateAd.getText("isPrebid")).thenReturn("1");
Mockito.when(nativeCustomTemplateAd.getText("hb_cache_id_local")).thenReturn(cacheId);
AdViewUtils.findNative(nativeCustomTemplateAd, new PrebidNativeAdListener() {
@Override
public void onPrebidNativeLoaded(PrebidNativeAd ad) {
assertTrue(ad != null);
}
@Override
public void onPrebidNativeNotFound() {
fail();
}
@Override
public void onPrebidNativeNotValid() {
fail();
}
});
}
use of com.google.android.gms.ads.formats.NativeCustomTemplateAd 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