com.applovin.sdk.AppLovinAd Java Examples

The following examples show how to use com.applovin.sdk.AppLovinAd. 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: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void showInterstitial()
{
    final AppLovinAd preloadedAd = dequeueAd( zoneId );
    if ( preloadedAd != null )
    {
        final AppLovinSdk sdk = AppLovinSdk.getInstance( context );

        final AppLovinInterstitialAdDialog interstitialAd = AppLovinInterstitialAd.create( sdk, context );
        interstitialAd.setAdDisplayListener( this );
        interstitialAd.setAdClickListener( this );
        interstitialAd.setAdVideoPlaybackListener( this );
        interstitialAd.showAndRender( preloadedAd );
    }
    else
    {
        log( ERROR, "Failed to show an AppLovin interstitial before one was loaded" );
        listener.onAdFailedToLoad( AdRequest.ERROR_CODE_INTERNAL_ERROR );
    }
}
 
Example #2
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void adReceived(final AppLovinAd ad)
{
    log( DEBUG, "Interstitial did load ad: " + ad.getAdIdNumber() );

    enqueueAd( ad, zoneId );

    runOnUiThread( new Runnable()
    {
        @Override
        public void run()
        {
            listener.onAdLoaded();
        }
    } );
}
 
Example #3
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 #4
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void showInterstitial()
{
    final AppLovinAd preloadedAd = dequeueAd( zoneId );
    if ( preloadedAd != null )
    {
        final AppLovinInterstitialAdDialog interstitialAd = AppLovinInterstitialAd.create( sdk, context );
        interstitialAd.setAdDisplayListener( this );
        interstitialAd.setAdClickListener( this );
        interstitialAd.setAdVideoPlaybackListener( this );
        interstitialAd.showAndRender( preloadedAd );
    }
    else
    {
        log( ERROR, "Failed to show an AppLovin interstitial before one was loaded" );
        listener.onInterstitialFailed( MoPubErrorCode.NETWORK_INVALID_STATE );
    }
}
 
Example #5
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void adReceived(final AppLovinAd ad)
{
    log( DEBUG, "Interstitial did load ad: " + ad.getAdIdNumber() );

    enqueueAd( ad, zoneId );

    runOnUiThread( new Runnable()
    {
        @Override
        public void run()
        {
            try
            {
                listener.onInterstitialLoaded();
            }
            catch ( Throwable th )
            {
                log( ERROR, "Unable to notify listener of successful ad load.", th );
            }
        }
    } );
}
 
Example #6
Source File: ApplovinAdapter.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
@Override
public void adReceived(final AppLovinAd ad)
{
    log( DEBUG, "Rewarded video did load ad: " + ad.getAdIdNumber() );

    runOnUiThread( new Runnable()
    {
        @Override
        public void run()
        {
            listener.onAdLoaded( ApplovinAdapter.this );
        }
    } );
}
 
Example #7
Source File: AppLovinIncentivizedAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void videoPlaybackEnded(AppLovinAd ad, double percentViewed, boolean fullyWatched) {
  ApplovinAdapter.log(
      DEBUG, "Rewarded video playback ended at playback percent: " + percentViewed + "%.");
  mFullyWatched = fullyWatched;
  if (fullyWatched) {
    mRewardedAdCallback.onVideoComplete();
  }
}
 
Example #8
Source File: AppLovinIncentivizedAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void userRewardVerified(AppLovinAd ad, Map<String, String> response) {
  final String currency = response.get("currency");
  final String amountStr = response.get("amount");

  // AppLovin returns amount as double.
  final int amount = (int) Double.parseDouble(amountStr);

  ApplovinAdapter.log(DEBUG, "Rewarded " + amount + " " + currency);
  mRewardItem = new AppLovinRewardItem(amount, currency);
}
 
Example #9
Source File: ApplovinAdapter.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
@Override
public void adClicked(final AppLovinAd ad)
{
    log( DEBUG, "Rewarded video clicked" );

    listener.onAdClicked( this );
    listener.onAdLeftApplication( this );
}
 
Example #10
Source File: AppLovinIncentivizedAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void adHidden(AppLovinAd ad) {
  ApplovinAdapter.log(DEBUG, "Rewarded video dismissed.");
  AppLovinMediationAdapter.INCENTIVIZED_ADS.remove(mZoneId);
  if (mFullyWatched) {
    mRewardedAdCallback.onUserEarnedReward(mRewardItem);
  }

  mRewardedAdCallback.onAdClosed();
}
 
Example #11
Source File: ApplovinAdapter.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
@Override
public void userRewardVerified(final AppLovinAd ad, final Map map)
{
    final String currency = (String) map.get( "currency" );
    final String amountStr = (String) map.get( "amount" );
    final int amount = (int) Double.parseDouble( amountStr ); // AppLovin returns amount as double

    log( DEBUG, "Verified " + amount + " " + currency );

    reward = new AppLovinRewardItem( amount, currency );
}
 
Example #12
Source File: ApplovinAdapter.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.getType() );
        listener.onRewarded( this, reward );
    }

    listener.onAdClosed( this );
}
 
Example #13
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
private static AppLovinAd dequeueAd(final String zoneId)
{
    synchronized ( GLOBAL_INTERSTITIAL_ADS_LOCK )
    {
        AppLovinAd preloadedAd = null;

        final Queue<AppLovinAd> preloadedAds = GLOBAL_INTERSTITIAL_ADS.get( zoneId );
        if ( preloadedAds != null && !preloadedAds.isEmpty() )
        {
            preloadedAd = preloadedAds.poll();
        }

        return preloadedAd;
    }
}
 
Example #14
Source File: AppLovinMediationAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void adReceived(final AppLovinAd appLovinAd) {
  ad = appLovinAd;
  Log.d("INFO", "Rewarded video did load ad: " + ad.getAdIdNumber());
  AppLovinSdkUtils.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          mRewardedAdCallback = mMediationAdLoadCallback.onSuccess(AppLovinMediationAdapter.this);
        }
      });
}
 
Example #15
Source File: AppLovinInterstitialAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void adClicked(AppLovinAd ad) {
  ApplovinAdapter.log(DEBUG, "Interstitial clicked.");

  mMediationInterstitialListener.onAdClicked(mAdapter);
  mMediationInterstitialListener.onAdLeftApplication(mAdapter);
}
 
Example #16
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
private static AppLovinAd dequeueAd(final String zoneId)
{
    synchronized ( GLOBAL_INTERSTITIAL_ADS_LOCK )
    {
        AppLovinAd preloadedAd = null;

        final Queue<AppLovinAd> preloadedAds = GLOBAL_INTERSTITIAL_ADS.get( zoneId );
        if ( preloadedAds != null && !preloadedAds.isEmpty() )
        {
            preloadedAd = preloadedAds.poll();
        }

        return preloadedAd;
    }
}
 
Example #17
Source File: ApplovinAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void showInterstitial() {
  synchronized (INTERSTITIAL_AD_QUEUES_LOCK) {
    // Update mute state.
    mSdk.getSettings().setMuted(AppLovinUtils.shouldMuteAudio(mNetworkExtras));

    final Queue<AppLovinAd> queue = INTERSTITIAL_AD_QUEUES.get(mZoneId);
    final AppLovinAd dequeuedAd = (queue != null) ? queue.poll() : null;

    final AppLovinInterstitialAdDialog interstitialAd =
        AppLovinInterstitialAd.create(mSdk, mContext);

    final AppLovinInterstitialAdListener listener =
        new AppLovinInterstitialAdListener(this, mMediationInterstitialListener);
    interstitialAd.setAdDisplayListener(listener);
    interstitialAd.setAdClickListener(listener);
    interstitialAd.setAdVideoPlaybackListener(listener);

    if (dequeuedAd != null) {
      log(DEBUG, "Showing interstitial for zone: " + mZoneId);
      interstitialAd.showAndRender(dequeuedAd);
    } else {
      log(DEBUG, "Attempting to show interstitial before one was loaded.");

      // Check if we have a default zone interstitial available.
      if (TextUtils.isEmpty(mZoneId) && interstitialAd.isAdReadyToDisplay()) {
        log(DEBUG, "Showing interstitial preloaded by SDK.");
        interstitialAd.show();
      }
      // TODO: Show ad for zone identifier if exists
      else {
        mMediationInterstitialListener.onAdOpened(this);
        mMediationInterstitialListener.onAdClosed(this);
      }
    }
  }
}
 
Example #18
Source File: AppLovinBannerAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void adReceived(final AppLovinAd ad) {
  ApplovinAdapter.log(
      DEBUG, "Banner did load ad: " + ad.getAdIdNumber() + " for zone: " + mZoneId);

  mAdView.renderAd(ad);

  AppLovinSdkUtils.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          mMediationBannerListener.onAdLoaded(mAdapter);
        }
      });
}
 
Example #19
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
@Override
public void userRewardVerified(final AppLovinAd appLovinAd, final Map map)
{
    final String currency = (String) map.get( "currency" );
    final int amount = (int) Double.parseDouble( (String) map.get( "amount" ) ); // AppLovin returns amount as double

    log( DEBUG, "Verified " + amount + " " + currency );

    reward = MoPubReward.success( currency, amount );
}
 
Example #20
Source File: AppLovinRtbInterstitialRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void adReceived(AppLovinAd ad) {
  Log.d(TAG, "Interstitial did load ad: " + ad.getAdIdNumber());

  this.ad = ad;
  mInterstitalAdCallback = callback.onSuccess(AppLovinRtbInterstitialRenderer.this);
}
 
Example #21
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 5 votes vote down vote up
@Override
public void videoPlaybackEnded(final AppLovinAd ad, final double percentViewed, final boolean fullyWatched)
{
    log( DEBUG, "Rewarded video playback ended at playback percent: " + percentViewed );

    this.fullyWatched = fullyWatched;
}
 
Example #22
Source File: AppLovinRtbBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void adReceived(AppLovinAd ad) {
  Log.d(TAG, "Banner did load ad: " + ad.getAdIdNumber());

  mBannerAdCallback = callback.onSuccess(AppLovinRtbBannerRenderer.this);
  adView.renderAd(ad);
}
 
Example #23
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 #24
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 #25
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
public void validationRequestFailed(final AppLovinAd appLovinAd, final int errorCode)
{
    log( ERROR, "Rewarded video validation request for ad failed with error code: " + errorCode );
}
 
Example #26
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
public void userOverQuota(final AppLovinAd appLovinAd, final Map map)
{
    log( ERROR, "Rewarded video validation request for ad did exceed quota with response: " + map );
}
 
Example #27
Source File: ApplovinAdapter.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
public void validationRequestFailed(final AppLovinAd appLovinAd, final int errorCode)
{
    log( ERROR, "Rewarded video validation request for ad failed with error code: " + errorCode );
}
 
Example #28
Source File: ApplovinAdapter.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" );
}
 
Example #29
Source File: AppLovinRtbBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adClicked(AppLovinAd ad) {
  Log.d(TAG, "Banner clicked.");
  mBannerAdCallback.reportAdClicked();
}
 
Example #30
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(), "" );
}