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


Java NativeExpressAdView.setAdListener方法代码示例

本文整理汇总了Java中com.google.android.gms.ads.NativeExpressAdView.setAdListener方法的典型用法代码示例。如果您正苦于以下问题:Java NativeExpressAdView.setAdListener方法的具体用法?Java NativeExpressAdView.setAdListener怎么用?Java NativeExpressAdView.setAdListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.ads.NativeExpressAdView的用法示例。


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

示例1: initializeAds

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public static void initializeAds(Context context, View bannerPlaceholder, NativeExpressAdView adView, AnalyticsHelper analyticsHelper, String screenName) {
    initializeAds(context, adView);

    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            apply(bannerPlaceholder, GONE);
            apply(adView, VISIBLE);
        }

        @Override
        public void onAdFailedToLoad(int i) {
            analyticsHelper.logScreenEvent(screenName, AD_FAILED_TO_LOAD);
        }

        @Override
        public void onAdClicked() {
            analyticsHelper.logScreenEvent(screenName, AD_CLICKED);
        }
    });
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:22,代码来源:Ads.java

示例2: request

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);

        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {

            mIsImpressionConfirmed = false;
            mIsReady = false;
            mAdView = null;
            mNativeAd = new NativeExpressAdView(mContext);
            mNativeAd.setAdSize(new AdSize(WIDTH,HEIGHT));
            mNativeAd.setAdUnitId(unitId);
            mNativeAd.setAdListener(mAdListener);
            mNativeAd.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:23,代码来源:AdMobNativeExpressAdapter.java

示例3: request

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);
        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {

            mIsReady = false;
            mAdView = null;
            mIsImpressionConfirmed = false;
            mNativeAd = new NativeExpressAdView(mContext);
            mNativeAd.setAdSize(AdSize.MEDIUM_RECTANGLE);
            mNativeAd.setAdUnitId(unitId);
            mNativeAd.setAdListener(mAdListener);
            mNativeAd.loadAd(AdMob.getAdRequest(context));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:22,代码来源:AdMobNativeExpressAdapter.java

示例4: setupAd

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
/**
 * Subscribing to the native ads events
 * @param adView
 */
protected synchronized void setupAd(final NativeExpressAdView adView) {
    if(mFetchFailCount > MAX_FETCH_ATTEMPT)
        return;

    if(!mPrefetchedAds.contains(adView))
        mPrefetchedAds.add(adView);
    adView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            // Handle the failure by logging, altering the UI, etc.
            onFailedToLoad(adView, errorCode);
        }
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            onFetched(adView);
        }
    });
}
 
开发者ID:clockbyte,项目名称:admobadapter,代码行数:25,代码来源:AdmobFetcherExpress.java

示例5: request

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
    if (context == null || networkData == null) {
        invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
    } else {
        String unitId = networkData.get(AdMob.KEY_UNIT_ID);
        if (TextUtils.isEmpty(unitId)) {
            invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
        } else {
            mIsImpressionConfirmed = false;
            mAdView = null;
            mNativeAd = new NativeExpressAdView(mContext);

            DisplayMetrics displayMetrics = new DisplayMetrics();

            if(context instanceof Activity) {
                ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                int heightDP = PNDeviceUtils.convertPxToDp(displayMetrics.heightPixels, context);
                heightDP = Math.min(Math.max(heightDP, MIN_HEIGHT), MAX_HEIGHT);
                int widthDP = PNDeviceUtils.convertPxToDp(displayMetrics.widthPixels, context);
                widthDP = Math.min(Math.max(widthDP, MIN_WIDTH), MAX_WIDTH);
                mNativeAd.setAdSize(new AdSize(widthDP, heightDP));
                mNativeAd.setAdUnitId(unitId);
                mNativeAd.setAdListener(mAdListener);
                mNativeAd.loadAd(AdMob.getAdRequest(context));
            } else {
                invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
            }
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:32,代码来源:AdMobNativeExpressAdapter.java

示例6: initBannerAds

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
private void initBannerAds() {
    // Look up the AdView as a resource and load a request.
    NativeExpressAdView adView = (NativeExpressAdView)this.findViewById(R.id.main_adView);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("BABB35E2F44BD42D7B74D736D34239F2")
            .build();
    adView.loadAd(adRequest);

    //Mechanism to prevent interstitial displaying when banner is active
    adView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            // Code to be executed when an ad finishes loading.
            isAdActive = false;
        }
        @Override
        public void onAdOpened() {
            // Code to be executed when an ad opens an overlay that
            // covers the screen.
            isAdActive = true;
        }

        @Override
        public void onAdLeftApplication() {
            // Code to be executed when the user has left the app.
            isAdActive = true;
        }

    });
}
 
开发者ID:ruibar,项目名称:android-protwall,代码行数:32,代码来源:ActivityFirst.java

示例7: AdNativeExpress

import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public AdNativeExpress(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    LayoutInflater.from(context).inflate(R.layout.ad_native_express_view, this);
    mNativeAdLayout = (FrameLayout) findViewById(R.id.ad_layout);
    mProgress = findViewById(R.id.progress);
    mAdText = findViewById(R.id.ad_text);
    mGHImage = (AppCompatImageView) findViewById(R.id.gh_image);

    findViewById(R.id.remove_ad).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ViewUtils.dialogDonate(v.getContext()).show();
        }
    });

    mNativeExpressAdView = new NativeExpressAdView(context);
    mNativeExpressAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mNativeExpressAdView.setAdUnitId(getContext().getString(Utils.DARK_THEME ?
            R.string.native_express_id_dark : R.string.native_express_id_light));
    mNativeExpressAdView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            mNativeLoading = false;
            mNativeLoaded = false;
            mNativeFailedLoading = true;
            loadGHAd();
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mNativeLoaded = true;
            mNativeLoading = false;
            mNativeFailedLoading = false;
            mProgress.setVisibility(GONE);
            mNativeAdLayout.addView(mNativeExpressAdView);
        }
    });
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:43,代码来源:AdNativeExpress.java


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