From e2d237527582a7d951f592570906d02cc3c93a42 Mon Sep 17 00:00:00 2001 From: agamemnus Date: Sat, 13 Dec 2014 00:54:48 -0500 Subject: [PATCH] loadAd before setAdListener? Not too sure about this, but seems to prevent an occasional error.... could be very wrong... --- src/android/AdMob.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/android/AdMob.java b/src/android/AdMob.java index fdeb879..3f5c076 100644 --- a/src/android/AdMob.java +++ b/src/android/AdMob.java @@ -200,12 +200,11 @@ private PluginResult executeCreateBannerView(JSONObject options, final CallbackC cordova.getActivity().runOnUiThread(new Runnable(){ @Override public void run() { - + boolean adViewWasNull = (adView == null); if(adView == null) { adView = new AdView(cordova.getActivity()); adView.setAdUnitId(publisherId); adView.setAdSize(adSize); - adView.setAdListener(new BannerListener()); } if (adView.getParent() != null) { ((ViewGroup)adView.getParent()).removeView(adView); @@ -221,7 +220,7 @@ public void run() { bannerVisible = false; adView.loadAd( buildAdRequest() ); - + if (adViewWasNull) adView.setAdListener (new BannerListener()); if(autoShowBanner) { executeShowAd(true, null); } @@ -281,9 +280,8 @@ private PluginResult executeCreateInterstitialView(JSONObject options, CallbackC public void run() { interstitialAd = new InterstitialAd(cordova.getActivity()); interstitialAd.setAdUnitId(interstialAdId); + interstitialAd.loadAd(buildAdRequest()); interstitialAd.setAdListener(new InterstitialListener()); - - interstitialAd.loadAd( buildAdRequest() ); delayCallback.success(); } });