com.mopub.mobileads.MoPubRewardedVideoManager Java Examples

The following examples show how to use com.mopub.mobileads.MoPubRewardedVideoManager. 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: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void failedToReceiveAd(final int errorCode)
{
    log( DEBUG, "Rewarded video failed to load with error: " + errorCode );

    parentActivity.runOnUiThread( new Runnable()
    {
        @Override
        public void run()
        {
            try
            {
                MoPubRewardedVideoManager.onRewardedVideoLoadFailure( AppLovinCustomEventRewardedVideo.this.getClass(), "", toMoPubErrorCode( errorCode ) );
            }
            catch ( Throwable th )
            {
                log( ERROR, "Unable to notify listener of failure to receive ad.", th );
            }
        }
    } );
}
 
Example #2
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void adReceived(final AppLovinAd ad)
{
    log( DEBUG, "Rewarded video did load ad: " + ad.getAdIdNumber() );

    parentActivity.runOnUiThread( new Runnable()
    {
        @Override
        public void run()
        {
            try
            {
                MoPubRewardedVideoManager.onRewardedVideoLoadSuccess( AppLovinCustomEventRewardedVideo.this.getClass(), "" );
            }
            catch ( Throwable th )
            {
                log( ERROR, "Unable to notify listener of successful ad load.", th );
            }
        }
    } );
}
 
Example #3
Source File: InMobiRewardedCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onAdRewardActionCompleted(InMobiInterstitial ad, Map<Object, Object> rewards) {
  Log.d(TAG, "InMobi Rewarded video onRewardActionCompleted.");
  if (null != rewards) {
    Iterator<Object> iterator = rewards.keySet()
        .iterator();
    String key = "", value = "";
    while (iterator.hasNext()) {
      key = iterator.next()
          .toString();
      value = rewards.get(key)
          .toString();
      Log.d("Rewards: ", key + ":" + value);
    }
    MoPubRewardedVideoManager.onRewardedVideoCompleted(InMobiRewardedCustomEvent.class, null,
        MoPubReward.success(key, Integer.parseInt(value)));
  }
}
 
Example #4
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
protected void showVideo()
{
    if ( hasVideoAvailable() )
    {
        fullyWatched = false;
        reward = null;

        incentivizedInterstitial.show( parentActivity, null, this, this, this, this );
    }
    else
    {
        log( ERROR, "Failed to show an AppLovin rewarded video before one was loaded" );
        MoPubRewardedVideoManager.onRewardedVideoPlaybackError( getClass(), "", MoPubErrorCode.VIDEO_PLAYBACK_ERROR );
    }
}
 
Example #5
Source File: MoPubSingleton.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
public void loadRewardedAd(Context context,
    final String adUnitID,
    final MoPubRewardedVideoManager.RequestParameters requestParameters,
    final MoPubAdapterRewardedListener adapterRewardedListener) {
  if (hasListener(adUnitID)) {
    String errorMessage =
        "An ad has already been requested for the MoPub Ad Unit ID: " + adUnitID;
    adapterRewardedListener.onAdFailedToLoad(ERROR_AD_ALREADY_LOADED, errorMessage);
    return;
  }

  mListeners.put(adUnitID, new WeakReference<>(adapterRewardedListener));

  SdkConfiguration configuration = new SdkConfiguration.Builder(adUnitID).build();
  initializeMoPubSDK(context, configuration, new SdkInitializationListener() {
    @Override
    public void onInitializationFinished() {
      MoPubRewardedVideos.loadRewardedVideo(adUnitID, requestParameters);
    }
  });
}
 
Example #6
Source File: InMobiRewardedCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void showVideo() {
  if (this.hasVideoAvailable()) {
    inmobiInterstitial.show();
  } else {
    MoPubRewardedVideoManager.onRewardedVideoPlaybackError(InMobiRewardedCustomEvent.class,
        placementId, MoPubErrorCode.VIDEO_PLAYBACK_ERROR);
  }
}
 
Example #7
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
@Override
public void adHidden(final AppLovinAd ad)
{
    log( DEBUG, "Rewarded video dismissed" );

    if ( fullyWatched && reward != null )
    {
        log( DEBUG, "Rewarded" + reward.getAmount() + " " + reward.getLabel() );
        MoPubRewardedVideoManager.onRewardedVideoCompleted( getClass(), "", reward );
    }

    MoPubRewardedVideoManager.onRewardedVideoClosed( getClass(), "" );
}
 
Example #8
Source File: MoPubMediationAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void loadRewardedAd(
    final MediationRewardedAdConfiguration mediationRewardedAdConfiguration,
    MediationAdLoadCallback<MediationRewardedAd,
        MediationRewardedAdCallback> mediationAdLoadCallback) {

  Context context = mediationRewardedAdConfiguration.getContext();
  Bundle serverParameters = mediationRewardedAdConfiguration.getServerParameters();
  adUnitID = serverParameters.getString(MOPUB_AD_UNIT_KEY);

  if (TextUtils.isEmpty(adUnitID)) {
    String errorMessage = createAdapterError(ERROR_INVALID_SERVER_PARAMETERS,
        "Failed to request ad from MoPub: "
            + "Missing or Invalid MoPub Ad Unit ID.");
    Log.w(TAG, errorMessage);
    mediationAdLoadCallback.onFailure(errorMessage);
    return;
  }

  mAdLoadCallback = mediationAdLoadCallback;
  MoPubRewardedVideoManager.RequestParameters requestParameters =
      new MoPubRewardedVideoManager.RequestParameters(
          MoPubSingleton.getKeywords(mediationRewardedAdConfiguration, false),
          MoPubSingleton.getKeywords(mediationRewardedAdConfiguration, true),
          mediationRewardedAdConfiguration.getLocation()
      );
  MoPubSingleton.getInstance().loadRewardedAd(
      context, adUnitID, requestParameters, MoPubMediationAdapter.this);
}
 
Example #9
Source File: InMobiRewardedCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onAdLoadSucceeded(InMobiInterstitial ad) {
  Log.v(TAG, "Ad load succeeded");
  if (ad != null) {
    MoPubRewardedVideoManager.onRewardedVideoLoadSuccess(InMobiRewardedCustomEvent.class,
        placementId);
  }
}
 
Example #10
Source File: InMobiRewardedCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onAdLoadFailed(InMobiInterstitial ad, InMobiAdRequestStatus status) {

    Log.v(TAG, "Ad failed to load:" + status.getStatusCode()
        .toString());
    if (status.getStatusCode() == StatusCode.INTERNAL_ERROR) {
      MoPubRewardedVideoManager.onRewardedVideoLoadFailure(InMobiRewardedCustomEvent.class,
          getAdNetworkId(), MoPubErrorCode.INTERNAL_ERROR);
    } else if (status.getStatusCode() == StatusCode.REQUEST_INVALID) {
      MoPubRewardedVideoManager.onRewardedVideoLoadFailure(InMobiRewardedCustomEvent.class,
          getAdNetworkId(), MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
    } else if (status.getStatusCode() == StatusCode.NETWORK_UNREACHABLE) {
      MoPubRewardedVideoManager.onRewardedVideoLoadFailure(InMobiRewardedCustomEvent.class,
          getAdNetworkId(), MoPubErrorCode.NETWORK_INVALID_STATE);
    } else if (status.getStatusCode() == StatusCode.NO_FILL) {
      MoPubRewardedVideoManager.onRewardedVideoLoadFailure(InMobiRewardedCustomEvent.class,
          getAdNetworkId(), MoPubErrorCode.NO_FILL);
    } else if (status.getStatusCode() == StatusCode.REQUEST_TIMED_OUT) {
      MoPubRewardedVideoManager.onRewardedVideoLoadFailure(InMobiRewardedCustomEvent.class,
          getAdNetworkId(), MoPubErrorCode.NETWORK_TIMEOUT);
    } else if (status.getStatusCode() == StatusCode.SERVER_ERROR) {
      MoPubRewardedVideoManager.onRewardedVideoLoadFailure(InMobiRewardedCustomEvent.class,
          getAdNetworkId(), MoPubErrorCode.SERVER_ERROR);
    } else {
      MoPubRewardedVideoManager.onRewardedVideoLoadFailure(InMobiRewardedCustomEvent.class,
          getAdNetworkId(), MoPubErrorCode.UNSPECIFIED);
    }
  }
 
Example #11
Source File: DemoActivity.java    From prebid-mobile-android with Apache License 2.0 5 votes vote down vote up
private void loadMPRewardedVideo() {

        final Map<String, String> keywordsMap = new HashMap<>();
        adUnit.fetchDemand(keywordsMap, new OnCompleteListener() {
            @Override
            public void onComplete(ResultCode resultCode) {

                MoPubRewardedVideoManager.RequestParameters parameters = new MoPubRewardedVideoManager.RequestParameters(Util.convertMapToMoPubKeywords(keywordsMap));
                MoPubRewardedVideos.loadRewardedVideo(MP_ADUNITID_REWARDED, parameters, (MediationSettings) null);
            }
        });

    }
 
Example #12
Source File: InMobiRewardedCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdDismissed(InMobiInterstitial ad) {
  Log.v(TAG, "Ad dismissed");
  MoPubRewardedVideoManager.onRewardedVideoClosed(InMobiRewardedCustomEvent.class, placementId);
}
 
Example #13
Source File: InMobiRewardedCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdInteraction(InMobiInterstitial ad, Map<Object, Object> params) {
  Log.v(TAG, "Ad interaction");
  MoPubRewardedVideoManager.onRewardedVideoClicked(InMobiRewardedCustomEvent.class, placementId);
}
 
Example #14
Source File: InMobiRewardedCustomEvent.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onAdDisplayed(InMobiInterstitial ad) {
  Log.v(TAG, "Ad displayed");
  MoPubRewardedVideoManager.onRewardedVideoStarted(InMobiRewardedCustomEvent.class, placementId);
}
 
Example #15
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
public void adDisplayed(final AppLovinAd ad)
{
    log( DEBUG, "Rewarded video displayed" );
    MoPubRewardedVideoManager.onRewardedVideoStarted( getClass(), "" );
}
 
Example #16
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
public void adClicked(final AppLovinAd ad)
{
    log( DEBUG, "Rewarded video clicked" );
    MoPubRewardedVideoManager.onRewardedVideoClicked( getClass(), "" );
}
 
Example #17
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
public void userDeclinedToViewAd(final AppLovinAd appLovinAd)
{
    log( DEBUG, "User declined to view rewarded video" );
    MoPubRewardedVideoManager.onRewardedVideoClosed( getClass(), "" );
}