com.inmobi.ads.InMobiNative Java Examples

The following examples show how to use com.inmobi.ads.InMobiNative. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override public void onAdLoadSucceeded(final InMobiNative inMobiNative) {
  super.onAdLoadSucceeded(inMobiNative);
  Log.i(TAG, "InMobi Native Ad loaded successfully");

  final List<String> imageUrls = new ArrayList<>();
  final String iconImageUrl = getAdIconUrl();
  if (iconImageUrl != null) {
    imageUrls.add(iconImageUrl);
  }
  preCacheImages(mContext, imageUrls, new NativeImageHelper.ImageListener() {
    @Override public void onImagesCached() {
      mCustomEventNativeListener.onNativeAdLoaded(InMobiNativeAd.this);
    }

    @Override public void onImagesFailedToCache(NativeErrorCode errorCode) {
      mCustomEventNativeListener.onNativeAdFailed(errorCode);
    }
  });
  STATIC_MAP.remove(this.hashCode());
}
 
Example #2
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override public void onAdLoadSucceeded(@NonNull InMobiNative inMobiNative) {
  Log.i(TAG, "InMobi Native Ad loaded successfully");

  final List<String> imageUrls = new ArrayList<>();
  final String iconImageUrl = getAdIconUrl();
  if (iconImageUrl != null) {
    imageUrls.add(iconImageUrl);
  }
  preCacheImages(mContext, imageUrls, new NativeImageHelper.ImageListener() {
    @Override public void onImagesCached() {
      mCustomEventNativeListener.onNativeAdLoaded(InMobiNativeAd.this);
    }

    @Override public void onImagesFailedToCache(NativeErrorCode errorCode) {
      mCustomEventNativeListener.onNativeAdFailed(errorCode);
    }
  });
  STATIC_MAP.remove(this.hashCode());
}
 
Example #3
Source File: InMobiUnifiedNativeAdMapper.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
public InMobiUnifiedNativeAdMapper(
    InMobiAdapter inMobiAdapter,
    InMobiNative inMobiNative,
    Boolean isOnlyURL,
    MediationNativeListener mediationNativeListener) {
  this.mInMobiAdapter = inMobiAdapter;
  this.mInMobiNative = inMobiNative;
  this.mIsOnlyURL = isOnlyURL;
  this.mMediationNativeListener = mediationNativeListener;
}
 
Example #4
Source File: InMobiAppInstallNativeAdMapper.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
public InMobiAppInstallNativeAdMapper(
    InMobiAdapter inMobiAdapter,
    InMobiNative inMobiNative,
    Boolean isOnlyURL,
    MediationNativeListener mediationNativeListener) {
  this.mInMobiAdapter = inMobiAdapter;
  this.mInMobiNative = inMobiNative;
  this.mIsOnlyURL = isOnlyURL;
  this.mMediationNativeListener = mediationNativeListener;
}
 
Example #5
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdLoadSucceeded(InMobiNative inMobiNative) {
    if (inMobiNative != null) {
        if (controller != null) {
            InMobiNativeAdResponse response = new InMobiNativeAdResponse();
            if (response.setResources(inMobiNative)) {
                weakReferenceInMobiNativeAdResponse = new WeakReference<InMobiNativeAdResponse>(response);
                controller.onAdLoaded(response);
            } else {
                controller.onAdFailed(ResultCode.UNABLE_TO_FILL);
            }
        }

    }
}
 
Example #6
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdLoadFailed(InMobiNative inMobiNative, InMobiAdRequestStatus inMobiAdRequestStatus) {
    Clog.e(Clog.mediationLogTag, "InMobiNative: " + inMobiAdRequestStatus.toString());
    if (controller != null) {
        controller.onAdFailed(InMobiSettings.getResultCode(inMobiAdRequestStatus));
    }
}
 
Example #7
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onAdClicked(final InMobiNative inMobiNative) {
  super.onAdClicked(inMobiNative);
  Log.d(TAG, "InMobi Native ad is clicked");
  if (!mIsClickRecorded) {
    notifyAdClicked();
    mIsClickRecorded = true;
  }
}
 
Example #8
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onAdImpressed(final InMobiNative inMobiNative) {
  super.onAdImpressed(inMobiNative);
  Log.d(TAG, "InMobi Native ad is displayed");
  if (!mIsImpressionRecorded) {
    mIsImpressionRecorded = true;
    notifyAdImpressed();
  }
}
 
Example #9
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onUserWillLeaveApplication(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onUserWillLeaveApplication");
    InMobiNativeAdResponse response = this.weakReferenceInMobiNativeAdResponse.get();
    if (response != null) {
        NativeAdEventListener listener = response.getListener();
        if (listener != null) {
            listener.onAdWillLeaveApplication();
        }
    }
}
 
Example #10
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdImpressed(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onAdImpressed");
    if(controller!=null) {
        controller.onAdImpression();
    }
}
 
Example #11
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onAdClicked(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onAdClicked");
    InMobiNativeAdResponse response = this.weakReferenceInMobiNativeAdResponse.get();
    if (response != null) {
        NativeAdEventListener listener = response.getListener();
        if (listener != null) {
            listener.onAdWasClicked();
        }
    }
}
 
Example #12
Source File: InMobiNativeAdResponse.java    From mobile-sdk-android with Apache License 2.0 5 votes vote down vote up
boolean setResources(final InMobiNative imNative) {
    this.imNative = imNative;
    try {
        nativeElements.put(NATIVE_ELEMENT_OBJECT, imNative);

        // Directly referenced from getters
        title = imNative.getAdTitle();
        description = imNative.getAdDescription();
        callToAction = imNative.getAdCtaText();
        landingUrl = imNative.getAdLandingPageUrl();


        // Extracted out of getCustomAdContent
        JSONObject response = imNative.getCustomAdContent();
        int length = JsonUtil.getJSONString(response, InMobiSettings.IMPRESSION_TRACKERS).length();
        impressionTrackers = JsonUtil.getJSONString(response, InMobiSettings.IMPRESSION_TRACKERS).substring(2,length-2).split("\",\"");
        JSONObject iconObject = JsonUtil.getJSONObject(response, InMobiSettings.KEY_ICON);
        iconUrl = JsonUtil.getJSONString(iconObject, InMobiSettings.KEY_URL);
        JSONObject imageObject = JsonUtil.getJSONObject(response, InMobiSettings.KEY_IMAGE);
        imageUrl = JsonUtil.getJSONString(imageObject, InMobiSettings.KEY_URL);
        if (JsonUtil.getJSONDouble(response, InMobiSettings.KEY_RATING) >= 0) {
            rating = new Rating(JsonUtil.getJSONDouble(response, InMobiSettings.KEY_RATING), 5);
        }


        clickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imNative.reportAdClickAndOpenLandingPage(); // no additional params passed in for click tracking
            }
        };
        return true;
    } catch (Exception e) {
        // Catches JSONException for parsing,
        // ClassCastException for String casting,
        // NPE for null imNative
    }
    return false;
}
 
Example #13
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onAdFullScreenDisplayed(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onAdFullScreenDisplayed");
}
 
Example #14
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onAdFullScreenWillDisplay(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onAdFullScreenWillDisplay");
}
 
Example #15
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onAdFullScreenDismissed(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onAdFullScreenDismissed");
}
 
Example #16
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onAdReceived(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onAdReceived");
}
 
Example #17
Source File: InMobiNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onAdStatusChanged(InMobiNative inMobiNative) {
    Clog.d(Clog.mediationLogTag, "InMobiNative - onAdStatusChanged");
}
 
Example #18
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdClicked(@NonNull InMobiNative InMobiNative) {
  if (!mIsClickRecorded) {
    notifyAdClicked();
    mIsClickRecorded = true;
  }
}
 
Example #19
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdImpressed(@NonNull InMobiNative InMobiNative) {
  if (!mIsImpressionRecorded) {
    mIsImpressionRecorded = true;
    notifyAdImpressed();
  }
}
 
Example #20
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdLoadFailed(@NonNull InMobiNative InMobiNative,
    @NonNull InMobiAdRequestStatus requestStatus) {
  String errorMessage = "Failed to load Native Strand:";
  switch (requestStatus.getStatusCode()) {
    case INTERNAL_ERROR:
      errorMessage += "INTERNAL_ERROR";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_INVALID_STATE);
      break;

    case REQUEST_INVALID:
      errorMessage += "INVALID_REQUEST";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_INVALID_REQUEST);
      break;

    case NETWORK_UNREACHABLE:
      errorMessage += "NETWORK_UNREACHABLE";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.CONNECTION_ERROR);
      break;

    case NO_FILL:
      errorMessage += "NO_FILL";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_NO_FILL);
      break;

    case REQUEST_PENDING:
      errorMessage += "REQUEST_PENDING";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;

    case REQUEST_TIMED_OUT:
      errorMessage += "REQUEST_TIMED_OUT";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_TIMEOUT);
      break;

    case SERVER_ERROR:
      errorMessage += "SERVER_ERROR";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.SERVER_ERROR_RESPONSE_CODE);
      break;

    case AD_ACTIVE:
      errorMessage += "AD_ACTIVE";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;

    case EARLY_REFRESH_REQUEST:
      errorMessage += "EARLY_REFRESH_REQUEST";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;

    default:
      errorMessage = "UNKNOWN_ERROR" + requestStatus.getStatusCode();
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;
  }
  Log.w(TAG, errorMessage);
  STATIC_MAP.remove(this.hashCode());
  destroy();
}
 
Example #21
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdStatusChanged(final InMobiNative inMobiNative) {
  super.onAdStatusChanged(inMobiNative);
  Log.d(TAG, "InMobi Native ad onAdStatusChanged");
}
 
Example #22
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onUserWillLeaveApplication(final InMobiNative inMobiNative) {
  super.onUserWillLeaveApplication(inMobiNative);
  Log.d(TAG, "InMobi Native ad onUserWillLeaveApplication");
}
 
Example #23
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdFullScreenDisplayed(final InMobiNative inMobiNative) {
  super.onAdFullScreenDisplayed(inMobiNative);
  Log.d(TAG, "InMobi Native ad onAdFullScreenDisplayed");
}
 
Example #24
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdFullScreenWillDisplay(final InMobiNative inMobiNative) {
  super.onAdFullScreenWillDisplay(inMobiNative);
  Log.d(TAG, "InMobi Native ad onAdFullScreenWillDisplay");
}
 
Example #25
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdFullScreenDismissed(final InMobiNative inMobiNative) {
  super.onAdFullScreenDismissed(inMobiNative);
  Log.d(TAG, "InMobi Native ad onAdFullScreenDismissed");
}
 
Example #26
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdLoadFailed(final InMobiNative inMobiNative,
    final InMobiAdRequestStatus inMobiAdRequestStatus) {
  super.onAdLoadFailed(inMobiNative, inMobiAdRequestStatus);
  String errorMessage = "Failed to load Native Strand:";
  switch (inMobiAdRequestStatus.getStatusCode()) {
    case INTERNAL_ERROR:
      errorMessage += "INTERNAL_ERROR";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_INVALID_STATE);
      break;

    case REQUEST_INVALID:
      errorMessage += "INVALID_REQUEST";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_INVALID_REQUEST);
      break;

    case NETWORK_UNREACHABLE:
      errorMessage += "NETWORK_UNREACHABLE";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.CONNECTION_ERROR);
      break;

    case NO_FILL:
      errorMessage += "NO_FILL";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_NO_FILL);
      break;

    case REQUEST_PENDING:
      errorMessage += "REQUEST_PENDING";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;

    case REQUEST_TIMED_OUT:
      errorMessage += "REQUEST_TIMED_OUT";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.NETWORK_TIMEOUT);
      break;

    case SERVER_ERROR:
      errorMessage += "SERVER_ERROR";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.SERVER_ERROR_RESPONSE_CODE);
      break;

    case AD_ACTIVE:
      errorMessage += "AD_ACTIVE";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;

    case EARLY_REFRESH_REQUEST:
      errorMessage += "EARLY_REFRESH_REQUEST";
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;

    default:
      errorMessage = "UNKNOWN_ERROR" + inMobiAdRequestStatus.getStatusCode();
      mCustomEventNativeListener.onNativeAdFailed(NativeErrorCode.UNSPECIFIED);
      break;
  }
  Log.w(TAG, errorMessage);
  STATIC_MAP.remove(this.hashCode());
  destroy();
}
 
Example #27
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 2 votes vote down vote up
@Override public void onAdStatusChanged(@NonNull InMobiNative inMobiNative) {

    }
 
Example #28
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 2 votes vote down vote up
@Override public void onUserSkippedMedia(@NonNull InMobiNative inMobiNative) {

    }
 
Example #29
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 2 votes vote down vote up
@Override public void onMediaPlaybackComplete(@NonNull InMobiNative inMobiNative) {

    }
 
Example #30
Source File: InMobiNativeCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 2 votes vote down vote up
@Override public void onUserWillLeaveApplication(InMobiNative inMobiNative) {

    }