com.applovin.adview.AppLovinAdView Java Examples

The following examples show how to use com.applovin.adview.AppLovinAdView. 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: AppLovinBannerAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
AppLovinBannerAdListener(
    String zoneId,
    AppLovinAdView adView,
    ApplovinAdapter adapter,
    MediationBannerListener mediationBannerListener) {
  mAdapter = adapter;
  mMediationBannerListener = mediationBannerListener;
  mAdView = adView;
  mZoneId = zoneId;
}
 
Example #2
Source File: AppLovinRtbBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
public void loadAd() {
  Context context = adConfiguration.getContext();
  if (!(context instanceof Activity)) {
    String adapterError =
        createAdapterError(
            ERROR_CONTEXT_NOT_ACTIVITY, "AppLovin requires an Activity context to load ads.");
    Log.e(TAG, "Failed to load banner ad from AppLovin: " + adapterError);
    callback.onFailure(adapterError);
    return;
  }

  AppLovinAdSize adSize =
      AppLovinUtils.appLovinAdSizeFromAdMobAdSize(context, adConfiguration.getAdSize());

  if (adSize == null) {
    String errorMessage =
        createAdapterError(
            ERROR_BANNER_SIZE_MISMATCH, "Failed to request banner with unsupported size.");
    callback.onFailure(errorMessage);
    return;
  }

  AppLovinSdk sdk = AppLovinUtils.retrieveSdk(adConfiguration.getServerParameters(), context);
  adView = new AppLovinAdView(sdk, adSize, context);
  adView.setAdDisplayListener(this);
  adView.setAdClickListener(this);
  adView.setAdViewEventListener(this);

  // Load ad!
  sdk.getAdService().loadNextAdForAdToken(adConfiguration.getBidResponse(), this);
}
 
Example #3
Source File: ApplovinAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void requestBannerAd(
    Context context,
    final MediationBannerListener mediationBannerListener,
    Bundle serverParameters,
    AdSize adSize,
    MediationAdRequest mediationAdRequest,
    Bundle networkExtras) {

  if (!(context instanceof Activity)) {
    String adapterError =
        createAdapterError(
            ERROR_CONTEXT_NOT_ACTIVITY, "AppLovin requires an Activity context to load ads.");
    log(ERROR, "Failed to load banner ad from AppLovin: " + adapterError);
    mediationBannerListener.onAdFailedToLoad(ApplovinAdapter.this, ERROR_CONTEXT_NOT_ACTIVITY);
    return;
  }

  // Store parent objects
  mSdk = AppLovinUtils.retrieveSdk(serverParameters, context);
  mZoneId = AppLovinUtils.retrieveZoneId(serverParameters);

  // Convert requested size to AppLovin Ad Size.
  final AppLovinAdSize appLovinAdSize =
      AppLovinUtils.appLovinAdSizeFromAdMobAdSize(context, adSize);
  if (appLovinAdSize == null) {
    String errorMessage =
        createAdapterError(
            ERROR_BANNER_SIZE_MISMATCH,
            "Failed to request banner with unsupported size: " + adSize.toString());
    log(ERROR, errorMessage);
    if (mediationBannerListener != null) {
      mediationBannerListener.onAdFailedToLoad(ApplovinAdapter.this, ERROR_BANNER_SIZE_MISMATCH);
    }
  }

  log(DEBUG, "Requesting banner of size " + appLovinAdSize + " for zone: " + mZoneId);
  mAdView = new AppLovinAdView(mSdk, appLovinAdSize, context);

  final AppLovinBannerAdListener listener =
      new AppLovinBannerAdListener(mZoneId, mAdView, this, mediationBannerListener);
  mAdView.setAdDisplayListener(listener);
  mAdView.setAdClickListener(listener);
  mAdView.setAdViewEventListener(listener);

  if (!TextUtils.isEmpty(mZoneId)) {
    mSdk.getAdService().loadNextAdForZoneId(mZoneId, listener);
  } else {
    mSdk.getAdService().loadNextAd(appLovinAdSize, listener);
  }
}
 
Example #4
Source File: AppLovinBannerAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adOpenedFullscreen(AppLovinAd ad, AppLovinAdView adView) {
  ApplovinAdapter.log(DEBUG, "Banner opened fullscreen.");
  mMediationBannerListener.onAdOpened(mAdapter);
}
 
Example #5
Source File: AppLovinBannerAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adClosedFullscreen(AppLovinAd ad, AppLovinAdView adView) {
  ApplovinAdapter.log(DEBUG, "Banner closed fullscreen.");
  mMediationBannerListener.onAdClosed(mAdapter);
}
 
Example #6
Source File: AppLovinBannerAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adLeftApplication(AppLovinAd ad, AppLovinAdView adView) {
  ApplovinAdapter.log(DEBUG, "Banner left application.");
  mMediationBannerListener.onAdLeftApplication(mAdapter);
}
 
Example #7
Source File: AppLovinBannerAdListener.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adFailedToDisplay(
    AppLovinAd ad, AppLovinAdView adView, AppLovinAdViewDisplayErrorCode code) {
  ApplovinAdapter.log(ERROR, "Banner failed to display: " + code);
}
 
Example #8
Source File: AppLovinRtbBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adOpenedFullscreen(AppLovinAd ad, AppLovinAdView adView) {
  Log.d(TAG, "Banner opened fullscreen.");
  mBannerAdCallback.onAdOpened();
}
 
Example #9
Source File: AppLovinRtbBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adClosedFullscreen(AppLovinAd ad, AppLovinAdView adView) {
  Log.d(TAG, "Banner closed fullscreen.");
  mBannerAdCallback.onAdClosed();
}
 
Example #10
Source File: AppLovinRtbBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adLeftApplication(AppLovinAd ad, AppLovinAdView adView) {
  Log.d(TAG, "Banner left application.");
  mBannerAdCallback.onAdLeftApplication();
}
 
Example #11
Source File: AppLovinRtbBannerRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 4 votes vote down vote up
@Override
public void adFailedToDisplay(
    AppLovinAd ad, AppLovinAdView adView, AppLovinAdViewDisplayErrorCode code) {
  Log.e(TAG, "Banner failed to display: " + code);
}