Beispiel #1
0
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      try {
        adLog.log(MASTAdLog.LOG_LEVEL_DEBUG, "OverrideUrlLoading", url);
        MASTAdDelegate delegate = adViewContainer.getAdDelegate();
        if (delegate != null) {
          MASTAdDelegate.AdActivityEventHandler clickHandler = delegate.getAdActivityEventHandler();
          if (clickHandler != null) {
            if (clickHandler.onAdClicked((MASTAdView) adViewContainer, url) == false) {
              // If click() method returns false, continue with
              // default logic
              defaultOnAdClickHandler((AdWebView) view, url);
            }
          } else {
            defaultOnAdClickHandler((AdWebView) view, url);
          }
        } else {
          defaultOnAdClickHandler((AdWebView) view, url);
        }
      } catch (Exception e) {
        adLog.log(MASTAdLog.LOG_LEVEL_ERROR, "shouldOverrideUrlLoading", e.getMessage());
      }

      return true;
    }
Beispiel #2
0
    @Override
    public void onReceivedError(
        WebView view, int errorCode, String description, String failingUrl) {
      super.onReceivedError(view, errorCode, description, failingUrl);

      adLog.log(MASTAdLog.LOG_LEVEL_ERROR, "onReceivedError", "" + errorCode + ":" + description);

      MASTAdDelegate delegate = adViewContainer.getAdDelegate();
      if (delegate != null) {
        MASTAdDelegate.AdDownloadEventHandler downloadHandler = delegate.getAdDownloadHandler();
        if (downloadHandler != null) {
          downloadHandler.onDownloadError((MASTAdView) adViewContainer, description);
        }
      }
    }
Beispiel #3
0
    @Override
    public void onPageFinished(WebView view, String url) {
      // if(isAutoCollapse) setAdVisibility(View.VISIBLE);

      MASTAdDelegate delegate = adViewContainer.getAdDelegate();
      if (delegate != null) {
        MASTAdDelegate.AdDownloadEventHandler downloadHandler = delegate.getAdDownloadHandler();
        if (downloadHandler != null) {
          // downloadHandler.onDownloadEnd((MASTAdView)adViewContainer);
          downloadHandler.onAdViewable((MASTAdView) adViewContainer);
        }
      }

      if (supportMraid) {
        // setDefaultPosition
        try {
          int x = AdSizeUtilities.devicePixelToMraidPoint(adViewContainer.getLeft(), context);
          int y = AdSizeUtilities.devicePixelToMraidPoint(adViewContainer.getTop(), context);
          int w = AdSizeUtilities.devicePixelToMraidPoint(adViewContainer.getWidth(), context);
          int h = AdSizeUtilities.devicePixelToMraidPoint(adViewContainer.getHeight(), context);

          JSONObject position = new JSONObject();
          position.put(
              MraidInterface.get_DEFAULT_POSITION_name(MraidInterface.DEFAULT_POSITION.X), "" + x);
          position.put(
              MraidInterface.get_DEFAULT_POSITION_name(MraidInterface.DEFAULT_POSITION.Y), "" + y);
          position.put(
              MraidInterface.get_DEFAULT_POSITION_name(MraidInterface.DEFAULT_POSITION.WIDTH),
              "" + w);
          position.put(
              MraidInterface.get_DEFAULT_POSITION_name(MraidInterface.DEFAULT_POSITION.HEIGHT),
              "" + h);
          injectJavaScript("mraid.setDefaultPosition(" + position.toString() + ");");
        } catch (Exception ex) {
          adLog.log(
              MASTAdLog.LOG_LEVEL_ERROR,
              "onPageFinished",
              "Error setting default position information.");
        }

        mraidInterface.setViewable(getVisibility() == View.VISIBLE);

        // Tell ad everything is ready, trigger state change from
        // loading to default
        mraidInterface.fireReadyEvent();
      }
    }