/*
  Result CB Code
  */
  @SuppressLint({
    "InlinedApi",
    "NewApi"
  }) /* suppress AsyncTask.THREAD_POOL_EXECUTOR warning for < HONEYCOMB */
  private void fireResultCB(final ResultCode result) {
    if (hasFailed) return;

    AdRequester requester = this.adFetcher.get();
    // if resultCB is empty don't fire resultCB, and just continue to next ad
    if ((currentAd == null) || StringUtil.isEmpty(currentAd.getResultCB())) {
      if (result == ResultCode.SUCCESS) return;
      Clog.w(Clog.mediationLogTag, Clog.getString(R.string.fire_cb_result_null));
      // just making sure
      if (requester == null) {
        Clog.e(Clog.httpRespLogTag, Clog.getString(R.string.fire_cb_requester_null));
        return;
      }
      requester.onReceiveResponse(null);
      return;
    }

    boolean ignoreResult = false; // default is to not ignore
    if ((requester != null) && (requester.getMediatedAds() != null)) {
      // ignore resultCB except on the last mediated ad
      ignoreResult = requester.getMediatedAds().size() > 0;
    }

    // ignore resultCB if succeeded already
    if (result == ResultCode.SUCCESS) {
      ignoreResult = true;
    }

    // fire call to result cb url
    ResultCBRequest cb =
        new ResultCBRequest(
            requester,
            currentAd.getResultCB(),
            result,
            currentAd.getExtras(),
            ignoreResult,
            getLatencyParam(),
            getTotalLatencyParam(requester));

    // Spawn GET call
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      cb.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
      cb.execute();
    }

    // if currentAd failed and next ad is available, continue to next ad
    if (ignoreResult && result != ResultCode.SUCCESS) {
      if (requester != null) {
        requester.onReceiveResponse(null);
      }
    }
  }
 private void handleInstantiationFailure(Throwable throwable, String className) {
   Clog.e(
       Clog.mediationLogTag,
       Clog.getString(
           R.string.mediation_instantiation_failure, throwable.getClass().getSimpleName()));
   if (!StringUtil.isEmpty(className)) {
     Clog.w(Clog.mediationLogTag, String.format("Adding %s to invalid networks list", className));
     Settings.getSettings().addInvalidNetwork(MediaType.NATIVE, className);
   }
   errorCode = ResultCode.MEDIATED_SDK_UNAVAILABLE;
 }
    @Override
    protected String getUrl() {
      // create the resultCB request
      StringBuilder sb = new StringBuilder(this.resultCB);
      sb.append("&reason=").append(this.result.ordinal());
      // append the hashes of the device ID from settings
      if (!StringUtil.isEmpty(Settings.getSettings().aaid)) {
        sb.append("&aaid=").append(Uri.encode(Settings.getSettings().aaid));
      } else {
        sb.append("&md5udid=").append(Uri.encode(Settings.getSettings().hidmd5));
        sb.append("&sha1udid=").append(Uri.encode(Settings.getSettings().hidsha1));
      }

      if (latency > 0) {
        sb.append("&latency=").append(Uri.encode(String.valueOf(latency)));
      }
      if (totalLatency > 0) {
        sb.append("&total_latency=").append(Uri.encode(String.valueOf(totalLatency)));
      }

      return sb.toString();
    }