예제 #1
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);
        }
      }
    }
예제 #2
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();
      }
    }