• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StaticNativeAd类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mopub.nativeads.StaticNativeAd的典型用法代码示例。如果您正苦于以下问题:Java StaticNativeAd类的具体用法?Java StaticNativeAd怎么用?Java StaticNativeAd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StaticNativeAd类属于com.mopub.nativeads包,在下文中一共展示了StaticNativeAd类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: update

import com.mopub.nativeads.StaticNativeAd; //导入依赖的package包/类
private void update(final TwitterStaticNativeAd staticNativeView,
        final StaticNativeAd staticNativeAd) {
    NativeRendererHelper.addTextView(staticNativeView.adTitleView,
            staticNativeAd.getTitle());
    NativeRendererHelper.addTextView(staticNativeView.adTextView, staticNativeAd.getText());
    NativeRendererHelper.addTextView(staticNativeView.callToActionView,
            staticNativeAd.getCallToAction());
    NativeImageHelper.loadImageView(staticNativeAd.getMainImageUrl(),
            staticNativeView.mainImageView);
    NativeImageHelper.loadImageView(staticNativeAd.getIconImageUrl(),
            staticNativeView.adIconView);
    NativeRendererHelper.addPrivacyInformationIcon(
            staticNativeView.privacyInfoView,
            staticNativeAd.getPrivacyInformationIconImageUrl(),
            staticNativeAd.getPrivacyInformationIconClickThroughUrl());
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:17,代码来源:TwitterStaticNativeAdRenderer.java


示例2: setUp

import com.mopub.nativeads.StaticNativeAd; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    Networking.setImageLoaderForTesting(mockImageLoader);
    doReturn(mockBitmap).when(mockImageContainer).getBitmap();

    doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        ((ImageLoader.ImageListener) args[1]).onResponse(mockImageContainer, true);
        return null;
    }).when(mockImageLoader).get(anyString(), any(ImageLoader.ImageListener.class));

    twitterStaticNativeAdRenderer = new TwitterStaticNativeAdRenderer();

    twitterStaticNativeAd = new TwitterStaticNativeAd(RuntimeEnvironment.application);
    twitterStaticNativeAd.adTextView = mock(TextView.class);
    twitterStaticNativeAd.adTitleView = mock(TextView.class);
    twitterStaticNativeAd.callToActionView = mock(TextView.class);
    twitterStaticNativeAd.mainImageView = mock(RoundedImageView.class);
    twitterStaticNativeAd.adIconView = mock(ImageView.class);
    twitterStaticNativeAd.privacyInfoView = mock(ImageView.class);

    staticNativeAd = new StaticNativeAd() { };
    staticNativeAd.setTitle(TEST_TITLE);
    staticNativeAd.setText(TEST_TEXT);
    staticNativeAd.setCallToAction(TEST_CTA);
    staticNativeAd.setClickDestinationUrl(TEST_URL);
    staticNativeAd.setMainImageUrl(TEST_URL);
    staticNativeAd.setIconImageUrl(TEST_URL);
    staticNativeAd.setPrivacyInformationIconClickThroughUrl(TEST_URL);
    staticNativeAd.setPrivacyInformationIconImageUrl(TEST_URL);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:34,代码来源:TwitterStaticNativeAdRendererTest.java


示例3: setResources

import com.mopub.nativeads.StaticNativeAd; //导入依赖的package包/类
boolean setResources(NativeAd response) {
    if (response != null) {
        this.mopubNativeAd = response;
        BaseNativeAd baseNativeAd = response.getBaseNativeAd();
        if (!(baseNativeAd instanceof StaticNativeAd)) {
            return false;
        }
        final StaticNativeAd staticNativeAd = (StaticNativeAd) baseNativeAd;

        this.title = staticNativeAd.getTitle();
        this.description = staticNativeAd.getText();
        this.imageUrl = staticNativeAd.getMainImageUrl();
        this.iconUrl = staticNativeAd.getIconImageUrl();
        this.callToAction = staticNativeAd.getCallToAction();
        if (staticNativeAd.getStarRating() != null) {
            this.rating = new Rating(staticNativeAd.getStarRating(), 5.0);
        }
        if (!staticNativeAd.getExtras().isEmpty()) {
            // put extras in native response, MoPub returns String as Object
            for (Map.Entry<String, Object> entry : staticNativeAd.getExtras().entrySet()) {
                nativeElements.put(entry.getKey(), entry.getValue());
            }
        }
        nativeElements.put(MoPubNativeSettings.NATIVE_ELEMENT_OBJECT, response);
        if (staticNativeAd.getPrivacyInformationIconImageUrl() != null) {
            nativeElements.put(MoPubNativeSettings.KEY_PRIVACYINFO_ICONURL, staticNativeAd.getPrivacyInformationIconImageUrl());
        }
        if (staticNativeAd.getPrivacyInformationIconClickThroughUrl() != null) {
            nativeElements.put(MoPubNativeSettings.KEY_PRIVACYINFO_LINKURL, staticNativeAd.getPrivacyInformationIconClickThroughUrl());
        }
        return true;
    }
    return false;
}
 
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:35,代码来源:MoPubNativeAdResponse.java


示例4: onBindViewHolder

import com.mopub.nativeads.StaticNativeAd; //导入依赖的package包/类
@Override
public void onBindViewHolder(final NativeAdViewHolder holder, final int position) {
    final NativeAd nativeAd = this.nativeAds.get(position);

    if (nativeAd != null) {
        holder.itemView.addOnAttachStateChangeListener(this);

        // Not sure what the previous ad type is, so just clear all of them
        NativeAdAdapter.clear(nativeAd, holder, NativeAdAdapter.ID_ADMOB_APP_INSTALL_AD_VIEW);
        NativeAdAdapter.clear(nativeAd, holder, NativeAdAdapter.ID_ADMOB_CONTENT_AD_VIEW);
        NativeAdAdapter.clear(nativeAd, holder, NativeAdAdapter.ID_ADMOB_NORMAL_AD_VIEW);

        final StaticNativeAd staticNativeAd = (StaticNativeAd)nativeAd.getBaseNativeAd();

        int viewId = 0;

        // AdMob native ads need special handling
        if (staticNativeAd instanceof AdMobNativeAd) {
            final com.google.android.gms.ads.formats.NativeAd ad = ((AdMobNativeAd)staticNativeAd).getNativeAd();

            if (ad instanceof NativeAppInstallAd) {
                holder.setAdType(NativeAdViewHolder.AD_TYPE_ADMOB_APP_INSTALL);

                viewId = NativeAdAdapter.ID_ADMOB_APP_INSTALL_AD_VIEW;
            } else if (ad instanceof NativeContentAd) {
                holder.setAdType(NativeAdViewHolder.AD_TYPE_ADMOB_CONTENT);

                viewId = NativeAdAdapter.ID_ADMOB_CONTENT_AD_VIEW;
            } else {
                Log.w(this.getClass().getSimpleName(), String.format("Unexpected AdMob native ad type: %s", ad.getClass()));
            }
        } else {
            holder.setAdType(NativeAdViewHolder.AD_TYPE_NORMAL);

            viewId = NativeAdAdapter.ID_ADMOB_NORMAL_AD_VIEW;
        }

        if (viewId > 0) {
            nativeAd.renderAdView(holder.adContainer.findViewById(viewId));
            nativeAd.prepare(holder.adContainer.findViewById(viewId));
        }

        NativeAdAdapter.resizeAdImage(holder, R.id.ad_image);
    }
}
 
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:46,代码来源:NativeAdAdapter.java


示例5: renderAdView

import com.mopub.nativeads.StaticNativeAd; //导入依赖的package包/类
@Override
public void renderAdView(final View view, final StaticNativeAd staticNativeAd) {
    update((TwitterStaticNativeAd) view, staticNativeAd);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:5,代码来源:TwitterStaticNativeAdRenderer.java


示例6: supports

import com.mopub.nativeads.StaticNativeAd; //导入依赖的package包/类
@Override
public boolean supports(final BaseNativeAd nativeAd) {
    return nativeAd instanceof StaticNativeAd;
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:5,代码来源:TwitterStaticNativeAdRenderer.java


示例7: testSupports_withCorrectInstanceOfBaseNativeAd_shouldReturnTrue

import com.mopub.nativeads.StaticNativeAd; //导入依赖的package包/类
@Test
public void testSupports_withCorrectInstanceOfBaseNativeAd_shouldReturnTrue() throws Exception {
    assertTrue(twitterStaticNativeAdRenderer.supports(new StaticNativeAd() {}));
    assertFalse(twitterStaticNativeAdRenderer.supports(mock(BaseNativeAd.class)));
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:6,代码来源:TwitterStaticNativeAdRendererTest.java



注:本文中的com.mopub.nativeads.StaticNativeAd类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DTMManagerDefault类代码示例发布时间:2022-05-23
下一篇:
Java FirebaseImageLoader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap