Package com.my.target.nativeads
Class NativeAd
- java.lang.Object
-
- com.my.target.common.BaseAd
-
- com.my.target.nativeads.NativeAd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceNativeAd.NativeAdChoicesListenerstatic interfaceNativeAd.NativeAdChoicesOptionListenerstatic interfaceNativeAd.NativeAdListenerstatic interfaceNativeAd.NativeAdMediaListener
-
Field Summary
-
Fields inherited from class com.my.target.common.BaseAd
adConfig, metricFactory
-
-
Constructor Summary
Constructors Constructor Description NativeAd(int slotId, android.content.Context context)Public constructorNativeAd(int slotId, MenuFactory menuFactory, android.content.Context context)Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NativeAd.NativeAdChoicesListenergetAdChoicesListener()NativeAd.NativeAdChoicesOptionListenergetAdChoicesOptionListener()Returns listener for ad choice menu.intgetAdChoicesPlacement()Retrieve current position for AdChoices iconjava.lang.StringgetAdSource()Get the name of source network.floatgetAdSourcePriority()Ad Source Priority is the value representing current ad network place in the queue of received advertisements.NativePromoBannergetBanner()Banner model for current ad.intgetCachePolicy()Retrieve current cachePolicy set previouslyNativeAd.NativeAdListenergetListener()Get events listener of an advertisementNativeAd.NativeAdMediaListenergetMediaListener()Gets listener for media objects events, such as icon loadingvoidhandleAdChoicesClick(android.content.Context context)Call to display adChoices options whose implementation has been passed using MenuFactory.voidhandleData(java.lang.String data)Loads data for s2s partnersvoidhandleSection(NativeAdSection section)booleanisMediationEnabled()Get enable/disable mediation flagbooleanisUseExoPlayer()Gets current flag of using ExoPlayer for video playingvoidload()Start loading ads.voidloadFromBid(java.lang.String bidId)Start loading ad with the bidding IDvoidregisterView(android.view.View view)Registration of the Advertising view.voidregisterView(android.view.View view, java.util.List<android.view.View> clickableViews)Registration of the Advertising view.voidsetAdChoicesListener(NativeAd.NativeAdChoicesListener adChoicesListener)Set events listener of adChoices icon load Must be called beforeload()voidsetAdChoicesOptionListener(NativeAd.NativeAdChoicesOptionListener adChoicesOptionListener)voidsetAdChoicesPlacement(int adChoicesPlacement)Sets the place for AdChoices icon, by default used top-right positionvoidsetCachePolicy(int cachePolicy)By default, images and videos are preloaded.voidsetListener(NativeAd.NativeAdListener listener)Set events listener of an advertisement Must be called beforeload()voidsetMediaListener(NativeAd.NativeAdMediaListener mediaListener)Sets listener for media objects events, such as icon loadingvoidsetMediationEnabled(boolean mediationEnabled)Enables/disables mediation for current ad.voidunregisterView()View de-registration.voiduseExoPlayer(boolean useExoPlayer)Enables/disables ExoPlayer to play video.-
Methods inherited from class com.my.target.common.BaseAd
getCustomParams, isLoadCalled, setAdNetworkConfig
-
-
-
-
Constructor Detail
-
NativeAd
public NativeAd(int slotId, @NonNull android.content.Context context)Public constructor- Parameters:
slotId- your slot idcontext- app context
-
NativeAd
public NativeAd(int slotId, @Nullable MenuFactory menuFactory, @NonNull android.content.Context context)Public constructor- Parameters:
slotId- your slot idcontext- app contextmenuFactory- menuFactory for drawing adChoices options
-
-
Method Detail
-
handleAdChoicesClick
public void handleAdChoicesClick(@NonNull android.content.Context context)Call to display adChoices options whose implementation has been passed using MenuFactory.
-
setCachePolicy
public void setCachePolicy(int cachePolicy)
By default, images and videos are preloaded. You can turn off the automatic loading of images and videos, but keep in mind that downloading them will take extra time, which will create an additional delay in displaying ads in your application.- Specified by:
setCachePolicyin interfaceINativeAd- Parameters:
cachePolicy- cache policy neededCachePolicy
-
getCachePolicy
public int getCachePolicy()
Retrieve current cachePolicy set previously- Specified by:
getCachePolicyin interfaceINativeAd- Returns:
- current cachePolicy
- See Also:
CachePolicy
-
getAdChoicesPlacement
public int getAdChoicesPlacement()
Retrieve current position for AdChoices icon- Specified by:
getAdChoicesPlacementin interfaceINativeAd- Returns:
- current adChoicesPlacement
- See Also:
AdChoicesPlacement
-
setAdChoicesPlacement
public void setAdChoicesPlacement(int adChoicesPlacement)
Sets the place for AdChoices icon, by default used top-right position- Specified by:
setAdChoicesPlacementin interfaceINativeAd- Parameters:
adChoicesPlacement- position- See Also:
AdChoicesPlacement
-
load
public final void load()
Start loading ads. In case of successful loading, the onLoad method will be called on the object passed as a listener, in case of loading error or if there is no advertisement to be shown - the onNoAdAd listener should be added before this call
-
loadFromBid
public void loadFromBid(@NonNull java.lang.String bidId)Start loading ad with the bidding ID- Specified by:
loadFromBidin interfaceINativeAd- Parameters:
bidId- bidding ID
-
registerView
public final void registerView(@NonNull android.view.View view, @Nullable java.util.List<android.view.View> clickableViews)Registration of the Advertising view. Must be called before showing the ad- Specified by:
registerViewin interfaceINativeAd- Parameters:
view- Advertising viewclickableViews- specific clickable views inside Advertising view. If set, the only views in this list will be clickable. Otherwise, whole view will be clickable
-
registerView
public final void registerView(@NonNull android.view.View view)Registration of the Advertising view. Must be called before showing the ad- Specified by:
registerViewin interfaceINativeAd- Parameters:
view- Advertising view
-
unregisterView
public final void unregisterView()
View de-registration. Stops timers, frees resources. Must be called after view is no longer needed- Specified by:
unregisterViewin interfaceINativeAd
-
handleData
public void handleData(@NonNull java.lang.String data)Loads data for s2s partners- Specified by:
handleDatain interfaceINativeAd- Parameters:
data- s2s data
-
getAdChoicesOptionListener
@Nullable public NativeAd.NativeAdChoicesOptionListener getAdChoicesOptionListener()
Returns listener for ad choice menu.- Returns:
- Object which implements
NativeAd.NativeAdChoicesOptionListenerinterface.
-
setAdChoicesOptionListener
public void setAdChoicesOptionListener(@Nullable NativeAd.NativeAdChoicesOptionListener adChoicesOptionListener)
-
setMediationEnabled
public void setMediationEnabled(boolean mediationEnabled)
Enables/disables mediation for current ad. Default is true. Disabling this option may cause lower fill-rate- Parameters:
mediationEnabled- if true - enable mediation, otherwise not
-
isMediationEnabled
public boolean isMediationEnabled()
Get enable/disable mediation flag- Returns:
- flag
-
getListener
@Nullable public NativeAd.NativeAdListener getListener()
Get events listener of an advertisement- Returns:
- an instance of listener
- See Also:
NativeAd.NativeAdListener
-
setListener
public void setListener(@Nullable NativeAd.NativeAdListener listener)Set events listener of an advertisement Must be called beforeload()- See Also:
NativeAd.NativeAdListener
-
getBanner
@Nullable public NativePromoBanner getBanner()
Banner model for current ad. Null if not loaded- Returns:
NativePromoBanner
-
handleSection
public final void handleSection(@NonNull NativeAdSection section)
-
useExoPlayer
public void useExoPlayer(boolean useExoPlayer)
Enables/disables ExoPlayer to play video. If exoplayer disabled, android default MediaPlayer will be used. Default is true, and it's recommended to not turn it off.- Parameters:
useExoPlayer- flag to use ExoPlayer- See Also:
- Android MediaPlayer, ExoPlayer
-
isUseExoPlayer
public boolean isUseExoPlayer()
Gets current flag of using ExoPlayer for video playing- Returns:
- param of using ExoPlayer
-
getAdSource
@Nullable public java.lang.String getAdSource()
Get the name of source network. It always will be "myTarget" if no mediation enabled. returns null if ad is not loaded- Returns:
- ad source
-
getAdSourcePriority
public float getAdSourcePriority()
Ad Source Priority is the value representing current ad network place in the queue of received advertisements. Works only with mediation. 0f if not loaded yet.- Returns:
- priority of ad source network
-
getMediaListener
@Nullable public NativeAd.NativeAdMediaListener getMediaListener()
Gets listener for media objects events, such as icon loading- Returns:
- listener object
- See Also:
NativeAd.NativeAdMediaListener
-
setMediaListener
public void setMediaListener(@Nullable NativeAd.NativeAdMediaListener mediaListener)Sets listener for media objects events, such as icon loading- Parameters:
mediaListener- listener object- See Also:
NativeAd.NativeAdMediaListener
-
setAdChoicesListener
public void setAdChoicesListener(@Nullable NativeAd.NativeAdChoicesListener adChoicesListener)Set events listener of adChoices icon load Must be called beforeload()- See Also:
NativeAd.NativeAdChoicesListener
-
getAdChoicesListener
@Nullable public NativeAd.NativeAdChoicesListener getAdChoicesListener()
- Returns:
- events listener of adChoices icon load
Must be called before
load() - See Also:
NativeAd.NativeAdChoicesListener
-
-