com.mopub.nativeads.NativeErrorCode Java Examples

The following examples show how to use com.mopub.nativeads.NativeErrorCode. 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: MoPubMediationAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
public static int getMediationErrorCode(@NonNull NativeErrorCode nativeErrorCode) {
  switch (nativeErrorCode) {
    case AD_SUCCESS:
      return 1000;
    case EMPTY_AD_RESPONSE:
      return 1001;
    case INVALID_RESPONSE:
      return 1002;
    case IMAGE_DOWNLOAD_FAILURE:
      return 1003;
    case INVALID_REQUEST_URL:
      return 1004;
    case UNEXPECTED_RESPONSE_CODE:
      return 1005;
    case SERVER_ERROR_RESPONSE_CODE:
      return 1006;
    case CONNECTION_ERROR:
      return 1007;
    case UNSPECIFIED:
      return 1008;
    case NETWORK_INVALID_REQUEST:
      return 1009;
    case NETWORK_TIMEOUT:
      return 1010;
    case NETWORK_NO_FILL:
      return 1011;
    case NETWORK_INVALID_STATE:
      return 1012;
    case NATIVE_RENDERER_CONFIGURATION_ERROR:
      return 1013;
    case NATIVE_ADAPTER_CONFIGURATION_ERROR:
      return 1014;
    case NATIVE_ADAPTER_NOT_FOUND:
      return 1015;
  }
  // Error '1099' to indicate that the error is new and has not been supported by the adapter yet.
  return 1099;
}
 
Example #2
Source File: AppLovinCustomEventNative.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
@Override
public void onNativeAdsLoaded(final List nativeAds)
{
    final AppLovinNativeAd nativeAd = (AppLovinNativeAd) nativeAds.get( 0 );

    log( DEBUG, "Native ad did load ad: " + nativeAd.getAdId() );

    final List<String> imageUrls = new ArrayList<>( 2 );

    if ( nativeAd.getIconUrl() != null ) imageUrls.add( nativeAd.getIconUrl() );
    if ( nativeAd.getImageUrl() != null ) imageUrls.add( nativeAd.getImageUrl() );

    // Please note: If/when we add support for videos, we must use AppLovin SDK's built-in precaching mechanism

    runOnUiThread( new Runnable()
    {
        @Override
        public void run()
        {
            NativeImageHelper.preCacheImages( context, imageUrls, new NativeImageHelper.ImageListener()
            {
                @Override
                public void onImagesCached()
                {
                    handleNativeAdFinishedCaching( nativeAd );
                }

                @Override
                public void onImagesFailedToCache(NativeErrorCode nativeErrorCode)
                {
                    handleNativeAdFinishedCaching( nativeAd );
                }
            } );
        }
    } );
}
 
Example #3
Source File: AppLovinCustomEventNative.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
private static NativeErrorCode toMoPubErrorCode(final int applovinErrorCode)
{
    if ( applovinErrorCode == AppLovinErrorCodes.NO_FILL )
    {
        return NativeErrorCode.NETWORK_NO_FILL;
    }
    else if ( applovinErrorCode == AppLovinErrorCodes.UNSPECIFIED_ERROR )
    {
        return NativeErrorCode.NETWORK_INVALID_STATE;
    }
    else if ( applovinErrorCode == AppLovinErrorCodes.NO_NETWORK )
    {
        return NativeErrorCode.CONNECTION_ERROR;
    }
    else if ( applovinErrorCode == AppLovinErrorCodes.FETCH_AD_TIMEOUT )
    {
        return NativeErrorCode.NETWORK_TIMEOUT;
    }
    else if ( applovinErrorCode == AppLovinErrorCodes.UNABLE_TO_PREPARE_NATIVE_AD )
    {
        return NativeErrorCode.INVALID_RESPONSE;
    }
    else
    {
        return NativeErrorCode.UNSPECIFIED;
    }
}
 
Example #4
Source File: MoPubMediationAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
public static String createSDKError(@NonNull NativeErrorCode error) {
  return String.format("%d: %s", getMediationErrorCode(error), error.toString());
}
 
Example #5
Source File: MoPubNativeAdListener.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onNativeFail(NativeErrorCode nativeErrorCode) {
    Clog.d(Clog.mediationLogTag, "MoPub: " + nativeErrorCode.toString());

    ResultCode code = ResultCode.INTERNAL_ERROR;

    switch (nativeErrorCode) {
        case EMPTY_AD_RESPONSE:
            code = ResultCode.UNABLE_TO_FILL;
            break;
        case IMAGE_DOWNLOAD_FAILURE:
            break;
        case INVALID_REQUEST_URL:
            break;
        case UNEXPECTED_RESPONSE_CODE:
            break;
        case SERVER_ERROR_RESPONSE_CODE:
            break;
        case CONNECTION_ERROR:
            code = ResultCode.NETWORK_ERROR;
            break;
        case UNSPECIFIED:
            break;
        case NETWORK_INVALID_REQUEST:
            code = ResultCode.NETWORK_ERROR;
            break;
        case NETWORK_TIMEOUT:
            code = ResultCode.NETWORK_ERROR;
            break;
        case NETWORK_NO_FILL:
            code = ResultCode.UNABLE_TO_FILL;
            break;
        case NETWORK_INVALID_STATE:
            code = ResultCode.NETWORK_ERROR;
            break;
        case NATIVE_ADAPTER_CONFIGURATION_ERROR:
            break;
        case NATIVE_ADAPTER_NOT_FOUND:
            break;
        default:
            Clog.w(Clog.mediationLogTag, "Unhandled Mopub error code: " + nativeErrorCode.toString());
            break;
    }

    controller.onAdFailed(code);
}