当前位置: 首页>>代码示例>>Java>>正文


Java NativeImageHelper类代码示例

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


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

示例1: update

import com.mopub.nativeads.NativeImageHelper; //导入依赖的package包/类
private void update(@NonNull final VM5MediaViewHolder mediaViewHolder,
                    @NonNull final VideoNativeAd videoNativeAd) {
    NativeRendererHelper.addTextView(mediaViewHolder.titleView,
            videoNativeAd.getTitle());
    NativeRendererHelper.addTextView(mediaViewHolder.textView, videoNativeAd.getText());
    NativeRendererHelper.addCtaButton(mediaViewHolder.callToActionView,
            mediaViewHolder.mainView, videoNativeAd.getCallToAction()
    );
    if (mediaViewHolder.mediaLayout != null) {
        NativeImageHelper.loadImageView(videoNativeAd.getMainImageUrl(),
                mediaViewHolder.mediaLayout.getMainImageView());
    }
    NativeImageHelper.loadImageView(videoNativeAd.getIconImageUrl(),
            mediaViewHolder.iconImageView);
    NativeRendererHelper.addPrivacyInformationIcon(
            mediaViewHolder.privacyInformationIconImageView,
            videoNativeAd.getPrivacyInformationIconImageUrl(),
            videoNativeAd.getPrivacyInformationIconClickThroughUrl());
}
 
开发者ID:VMFive,项目名称:android-sdk-3.0,代码行数:20,代码来源:VM5MoPubVideoNativeAdRenderer.java

示例2: update

import com.mopub.nativeads.NativeImageHelper; //导入依赖的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

示例3: onNativeAdsLoaded

import com.mopub.nativeads.NativeImageHelper; //导入依赖的package包/类
@Override
public void onNativeAdsLoaded(final List nativeAds)
{
    final AppLovinNativeAd nativeAd = (AppLovinNativeAd) nativeAds.get( 0 );

    log( DEBUG, "Native ad did load ad: " + nativeAd.getAdId() );

    final List<String> imageUrls = new ArrayList<>( 2 );

    if ( nativeAd.getIconUrl() != null ) imageUrls.add( nativeAd.getIconUrl() );
    if ( nativeAd.getImageUrl() != null ) imageUrls.add( nativeAd.getImageUrl() );

    // Please note: If/when we add support for videos, we must use AppLovin SDK's built-in precaching mechanism

    runOnUiThread( new Runnable()
    {
        @Override
        public void run()
        {
            NativeImageHelper.preCacheImages( context, imageUrls, new NativeImageHelper.ImageListener()
            {
                @Override
                public void onImagesCached()
                {
                    handleNativeAdFinishedCaching( nativeAd );
                }

                @Override
                public void onImagesFailedToCache(NativeErrorCode nativeErrorCode)
                {
                    handleNativeAdFinishedCaching( nativeAd );
                }
            } );
        }
    } );
}
 
开发者ID:AppLovin,项目名称:SDK-Network-Adaptors,代码行数:37,代码来源:AppLovinCustomEventNative.java

示例4: onAdLoaded

import com.mopub.nativeads.NativeImageHelper; //导入依赖的package包/类
@Override
public void onAdLoaded(AdObject adObject) {
    Log.d(TAG, "Native ad loaded successfully.");

    if (mAdDelegator == null) {
        mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_INVALID_STATE);
        return;
    }

    if (adObject.getAdTitle() != null && !adObject.getAdTitle().equals("")) {
        setTitle(adObject.getAdTitle());
    } else {
        setTitle("title");
    }
    if (adObject.getAdDescription() != null && !adObject.getAdDescription().equals("")) {
        setText(adObject.getAdDescription());
    } else {
        setText("description");
    }

    if (adObject.getImageUrl() != null) {
        setMainImageUrl(adObject.getImageUrl());
    }

    if (adObject.getIconUrl() != null) {
        setIconImageUrl(adObject.getIconUrl());
    }

    setClickDestinationUrl(adObject.getAdTrigger().getActionUrl());
    if (adObject.getAdCtaText() != null && !adObject.getAdCtaText().equals("")) {
        setCallToAction(adObject.getAdCtaText());
    } else {
        setCallToAction("More");
    }

    setStarRating(1.0);
    setImpressionMinTimeViewed(IMPRESSION_MIN_TIME_VIEWED);

    final List<String> imageUrls = new ArrayList<String>();
    final String mainImageUrl = getMainImageUrl();
    if (mainImageUrl != null) {
        imageUrls.add(mainImageUrl);
    }

    final String iconUrl = getIconImageUrl();
    if (iconUrl != null) {
        imageUrls.add(iconUrl);
    }

    preCacheImages(mContext, imageUrls, new NativeImageHelper.ImageListener() {
        @Override
        public void onImagesCached() {
            mCustomEventNativeListener.onNativeAdLoaded(VM5StaticNativeAd.this);
        }

        @Override
        public void onImagesFailedToCache(NativeErrorCode errorCode) {
            mCustomEventNativeListener.onNativeAdFailed(errorCode);
        }
    });
    onDestroy();
}
 
开发者ID:VMFive,项目名称:android-sdk-3.0,代码行数:63,代码来源:VM5NativeStatic.java

示例5: PMMoPubNativeAdAdapter

import com.mopub.nativeads.NativeImageHelper; //导入依赖的package包/类
public PMMoPubNativeAdAdapter(@NonNull NativeAd ad, final Context context, final CustomEventNative.CustomEventNativeListener customEventNativeListener) {
        this.customEventNativeListener = customEventNativeListener;
        this.ad = ad;
        this.context = context;

        NativeAdImages images = ad.getImages();

        setIconImageUrl(ad.getCampaignImage());
        if(images.getBanner() != null) {
            setMainImageUrl(images.getBanner().getUrl());
        }

        setTitle(ad.getCampaignName());
        setCallToAction(ad.getActionText());
        setText(ad.getCampaignDescription());

        setClickDestinationUrl(ad.getClickURL());

//        setPrivacyInformationIconClickThroughUrl(ad.getRedirectionUrl());
//        setPrivacyInformationIconImageUrl(ad.getIconUrl());

        final List<String> imageUrls = new ArrayList<String>();
        final String mainImageUrl = getMainImageUrl();
        if (mainImageUrl != null) {
            imageUrls.add(getMainImageUrl());
        }
        final String iconUrl = getIconImageUrl();
        if (iconUrl != null) {
            imageUrls.add(getIconImageUrl());
        }

        NativeImageHelper.preCacheImages(context, imageUrls, new NativeImageHelper.ImageListener() {
            @Override
            public void onImagesCached() {
                customEventNativeListener.onNativeAdLoaded(PMMoPubNativeAdAdapter.this);
            }

            @Override
            public void onImagesFailedToCache(NativeErrorCode errorCode) {
                customEventNativeListener.onNativeAdFailed(errorCode);
            }
        });

    }
 
开发者ID:Pocketbrain,项目名称:androidnativeadslib,代码行数:45,代码来源:PMMoPubNativeAdAdapter.java

示例6: trackView

import com.mopub.nativeads.NativeImageHelper; //导入依赖的package包/类
public void trackView(View view) {

        mMopubNativeAdData.prepare(view);

        if (!(view instanceof ViewGroup)) {
            return;
        }

        ViewGroup adView = (ViewGroup) view;

        View overlayView = adView.getChildAt(adView.getChildCount() - 1);
        if (overlayView instanceof FrameLayout) {

            final Context context = view.getContext();
            if (context == null) {
                return;
            }

            privacyInformationIconImageView = new ImageView(context);
            String privacyInformationImageUrl =
                    mMopubNativeAdData.getPrivacyInformationIconImageUrl();
            final String privacyInformationClickthroughUrl = mMopubNativeAdData
                    .getPrivacyInformationIconClickThroughUrl();

            if (privacyInformationImageUrl == null) {
                privacyInformationIconImageView.setImageDrawable(
                        Drawables.NATIVE_PRIVACY_INFORMATION_ICON.createDrawable(context));
            } else {
                NativeImageHelper.loadImageView(privacyInformationImageUrl,
                        privacyInformationIconImageView);
            }

            privacyInformationIconImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View v) {
                    new UrlHandler.Builder()
                            .withSupportedUrlActions(
                                    UrlAction.IGNORE_ABOUT_SCHEME,
                                    UrlAction.OPEN_NATIVE_BROWSER,
                                    UrlAction.OPEN_IN_APP_BROWSER,
                                    UrlAction.HANDLE_SHARE_TWEET,
                                    UrlAction.FOLLOW_DEEP_LINK_WITH_FALLBACK,
                                    UrlAction.FOLLOW_DEEP_LINK)
                            .build().handleUrl(context, privacyInformationClickthroughUrl);
                }
            });
            privacyInformationIconImageView.setVisibility(View.VISIBLE);
            ((ViewGroup) overlayView).addView(privacyInformationIconImageView);

            float scale = context.getResources().getDisplayMetrics().density;
            int icon_size_px = (int) (mPrivacyIconSize * scale + 0.5);
            FrameLayout.LayoutParams params =
                    new FrameLayout.LayoutParams(icon_size_px, icon_size_px);

            switch (privacyIconPlacement) {
                case NativeAdOptions.ADCHOICES_TOP_LEFT:
                    params.gravity = Gravity.TOP | Gravity.LEFT;
                    break;
                case NativeAdOptions.ADCHOICES_BOTTOM_RIGHT:
                    params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
                    break;
                case NativeAdOptions.ADCHOICES_BOTTOM_LEFT:
                    params.gravity = Gravity.BOTTOM | Gravity.LEFT;
                    break;
                case NativeAdOptions.ADCHOICES_TOP_RIGHT:
                    params.gravity = Gravity.TOP | Gravity.RIGHT;
                    break;
                default:
                    params.gravity = Gravity.TOP | Gravity.RIGHT;
            }
            privacyInformationIconImageView.setLayoutParams(params);
            adView.requestLayout();
        } else {
            Log.d(MoPubAdapter.TAG, "Failed to show AdChoices icon.");
        }


    }
 
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:79,代码来源:MoPubNativeAppInstallAdMapper.java

示例7: preCacheImages

import com.mopub.nativeads.NativeImageHelper; //导入依赖的package包/类
/**
* Helper method to pre-cache ad images.
* @param imageUrls A list of images to cache.
*/
protected void preCacheImages(@NonNull final List<String> imageUrls) {
    NativeImageHelper.preCacheImages(this.context, imageUrls, this.imageListener);
}
 
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:8,代码来源:BaseStaticNativeAd.java


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