@Override public void run() { if (adSize == null) { result = new PluginResult(Status.ERROR, "AdSize is null. Did you use an AdSize constant?"); } else { adView = new AdView(cordova.getActivity(), adSize, publisherId); adView.setAdListener(new BannerListener()); LinearLayoutSoftKeyboardDetect parentView = (LinearLayoutSoftKeyboardDetect) webView.getParent(); if (bannerAtTop) { parentView.addView(adView, 0); } else { parentView.addView(adView); } // Notify the plugin. result = new PluginResult(Status.OK); } synchronized (this) { this.notify(); } }
private void executeKillAd(final CallbackContext callbackContext) { final Runnable runnable = new Runnable() { public void run() { if (adView == null) { // Notify the plugin. callbackContext.error("AdView is null. Did you call createBannerView or already destroy it?"); } else { LinearLayoutSoftKeyboardDetect parentView = (LinearLayoutSoftKeyboardDetect) webView .getParent(); parentView.removeView(adView); adView.removeAllViews(); adView.destroy(); adView = null; callbackContext.success(); } } }; this.cordova.getActivity().runOnUiThread(runnable); }
@Override public void run() { if(adView != null) { LinearLayoutSoftKeyboardDetect parentView = (LinearLayoutSoftKeyboardDetect) webView.getParent(); parentView.removeView(adView); } // Notify the plugin. result = new PluginResult(Status.OK); synchronized (this) { this.notify(); } }
private synchronized void createBannerView(final String publisherId, final AdSize adSize, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; // Create the AdView on the UI thread. Log.w(LOGTAG, "createBannerView"); Runnable runnable = new Runnable() { public void run() { Log.w(LOGTAG, "run"); Log.w(LOGTAG, String.valueOf(webView)); // Log.w(LOGTAG, "adSize::" + adSize); calling adSize.toString() with SmartBanner == crash if (adSize == null) { callbackContext .error("AdSize is null. Did you use an AdSize constant?"); return; } else { adView = new DfpAdView(cordova.getActivity(), adSize, publisherId); adView.setAdListener(new BannerListener()); LinearLayoutSoftKeyboardDetect parentView = (LinearLayoutSoftKeyboardDetect) webView .getParent(); if (positionAtTop) { parentView.addView(adView, 0); } else { parentView.addView(adView); } // Notify the plugin. callbackContext.success(); } } }; this.cordova.getActivity().runOnUiThread(runnable); }