com.google.ads.mediation.customevent
Class CustomEventAdapter

java.lang.Object
  extended by com.google.ads.mediation.customevent.CustomEventAdapter
All Implemented Interfaces:
MediationAdapter<EmptyNetworkExtras,CustomEventServerParameters>, MediationBannerAdapter<EmptyNetworkExtras,CustomEventServerParameters>, MediationInterstitialAdapter<EmptyNetworkExtras,CustomEventServerParameters>

public class CustomEventAdapter
extends Object
implements MediationBannerAdapter<EmptyNetworkExtras,CustomEventServerParameters>, MediationInterstitialAdapter<EmptyNetworkExtras,CustomEventServerParameters>

An adapter for custom events.

This implements the logic for creating a custom event object and calling its requestInterstitialAd or requestBannerAd method. It also contains the logic for passing events back from the publisher custom event listener to the mediation framework. The custom event class name is passed as a server parameter. This adapter does not use an extra-parameters object and so the first generic parameter is Void.

Note that unlike "first-class" ad networks, multiple custom events in the same mediation placement would all share the same adapter class.


Constructor Summary
CustomEventAdapter()
           
 
Method Summary
 void destroy()
          Tears down the adapter control.
 Class<EmptyNetworkExtras> getAdditionalParametersType()
          Returns the class that provides additional parameters to this adapter.
 View getBannerView()
          Returns a View that can be rendered to display the ad.
 Class<CustomEventServerParameters> getServerParametersType()
          Returns the class that provides parameters set by the mediation backend to this adapter.
 void requestBannerAd(MediationBannerListener mediationListener, Activity activity, CustomEventServerParameters serverParameters, AdSize adSize, MediationAdRequest mediationAdRequest, EmptyNetworkExtras mediationExtras)
          Called by the mediation library to request an ad from the adapter.
 void requestInterstitialAd(MediationInterstitialListener mediationListener, Activity activity, CustomEventServerParameters serverParameters, MediationAdRequest mediationAdRequest, EmptyNetworkExtras mediationExtras)
          Called by the mediation library to request an ad from the adapter.
 void showInterstitial()
          Shows the interstitial.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomEventAdapter

public CustomEventAdapter()
Method Detail

requestBannerAd

public void requestBannerAd(MediationBannerListener mediationListener,
                            Activity activity,
                            CustomEventServerParameters serverParameters,
                            AdSize adSize,
                            MediationAdRequest mediationAdRequest,
                            EmptyNetworkExtras mediationExtras)
Description copied from interface: MediationBannerAdapter
Called by the mediation library to request an ad from the adapter.

If the request is successful, the MediationBannerListener.onReceivedAd(com.google.ads.mediation.MediationBannerAdapter) method should be called.

If the request is unsuccessful, the MediationBannerListener.onFailedToReceiveAd(com.google.ads.mediation.MediationBannerAdapter, com.google.ads.AdRequest.ErrorCode) method should be called on the listener with an appropriate error cause.

This method is called on the UI thread so all the standard precautions of writing code on that thread apply. In particular your code should not call any blocking methods.

Specified by:
requestBannerAd in interface MediationBannerAdapter<EmptyNetworkExtras,CustomEventServerParameters>
Parameters:
mediationListener - Listener to adapter with callbacks for various events
activity - Android Activity which is displaying the ad
serverParameters - Additional parameters defined by the publisher on the mediation server side
adSize - The size of the ad to fetch. The ad size returned should have size as close as possible to the size specified in this parameter. If this ad size is not supported the request should fail and MediationAdapterListener.onFailedToReceiveAd should be called.
mediationAdRequest - Generic parameters for this publisher to use when making his ad request
mediationExtras - Additional parameters set by the publisher on a per-request basis

getBannerView

public View getBannerView()
Description copied from interface: MediationBannerAdapter
Returns a View that can be rendered to display the ad.

This must not be null after a MediationBannerAdapter.requestBannerAd(com.google.ads.mediation.MediationBannerListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.AdSize, com.google.ads.mediation.MediationAdRequest, ADDITIONAL_PARAMETERS) call and before a MediationAdapter.destroy() call. It may be null any other time.

Specified by:
getBannerView in interface MediationBannerAdapter<EmptyNetworkExtras,CustomEventServerParameters>

showInterstitial

public void showInterstitial()
Description copied from interface: MediationInterstitialAdapter
Shows the interstitial. This may be called any time after a call to MediationInterstitialListener.onReceivedAd(com.google.ads.mediation.MediationInterstitialAdapter).

Specified by:
showInterstitial in interface MediationInterstitialAdapter<EmptyNetworkExtras,CustomEventServerParameters>

requestInterstitialAd

public void requestInterstitialAd(MediationInterstitialListener mediationListener,
                                  Activity activity,
                                  CustomEventServerParameters serverParameters,
                                  MediationAdRequest mediationAdRequest,
                                  EmptyNetworkExtras mediationExtras)
Description copied from interface: MediationInterstitialAdapter
Called by the mediation library to request an ad from the adapter.

If the request is successful, the MediationInterstitialListener.onReceivedAd(com.google.ads.mediation.MediationInterstitialAdapter) method should be called. The interstitial should *NOT* be automatically shown at this point. The mediation library will call the MediationInterstitialAdapter.showInterstitial() method when the interstitial should be shown.

If the request is unsuccessful, the MediationInterstitialListener.onFailedToReceiveAd(com.google.ads.mediation.MediationInterstitialAdapter, com.google.ads.AdRequest.ErrorCode) method should be called on the listener with an appropriate error cause.

Note that this method is called on the UI thread, so all the general precautions of writing code on that thread apply. In particular, the code should not call any blocking methods.

Specified by:
requestInterstitialAd in interface MediationInterstitialAdapter<EmptyNetworkExtras,CustomEventServerParameters>
Parameters:
mediationListener - Listener to adapter with callbacks for various events
activity - Android Activity which is displaying the ad
serverParameters - Additional parameters defined by the publisher on the mediation server side
mediationAdRequest - Generic parameters for this publisher to use when making his ad request
mediationExtras - Additional parameters set by the publisher on a per-request basis

getAdditionalParametersType

public Class<EmptyNetworkExtras> getAdditionalParametersType()
Description copied from interface: MediationAdapter
Returns the class that provides additional parameters to this adapter. This method may return null if there is no additional parameters class.

Specified by:
getAdditionalParametersType in interface MediationAdapter<EmptyNetworkExtras,CustomEventServerParameters>

getServerParametersType

public Class<CustomEventServerParameters> getServerParametersType()
Description copied from interface: MediationAdapter
Returns the class that provides parameters set by the mediation backend to this adapter. This method may return null if there is no server parameters class.

Specified by:
getServerParametersType in interface MediationAdapter<EmptyNetworkExtras,CustomEventServerParameters>

destroy

public void destroy()
Description copied from interface: MediationAdapter
Tears down the adapter control.

This is called at the end of the mediator's life cycle. The adapter is expected to release any resources and shut down. After this method is called, any subsequent calls to any other method on this adapter may throw an IllegalStateException.

This method is not guaranteed to be called. There are a number of reasons that this method can be skipped, such as a force close of the application.

Specified by:
destroy in interface MediationAdapter<EmptyNetworkExtras,CustomEventServerParameters>