public abstract class

MediaDisplayAdapter

extends Object
implements InAppMessageAdapter
java.lang.Object
   ↳ com.urbanairship.iam.MediaDisplayAdapter
Known Direct Subclasses

Class Overview

Display adapter that handles caching an in-app message.

Summary

[Expand]
Inherited Constants
From interface com.urbanairship.iam.InAppMessageAdapter
Protected Constructors
MediaDisplayAdapter(InAppMessage message, MediaInfo mediaInfo)
Default constructor.
Public Methods
boolean isReady(Activity activity)
Called before displaying but after the message is prepared.
boolean onDisplay(Activity activity, boolean isRedisplay, DisplayHandler displayHandler)
Called to display an in-app message.
void onFinish()
Called after the in-app message is finished displaying.
int onPrepare(Context context)
Called before onDisplay(Activity, boolean, DisplayHandler) to prepare the message to be displayed.
Protected Methods
int cacheMedia(Context context, MediaInfo mediaInfo)
Caches the media info.
void createCache(Context context)
Creates the cache.
InAppMessageCache getCache()
Gets the cache.
InAppMessage getMessage()
Gets the in-app message.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.urbanairship.iam.InAppMessageAdapter

Protected Constructors

protected MediaDisplayAdapter (InAppMessage message, MediaInfo mediaInfo)

Default constructor.

Parameters
message The in-app message.
mediaInfo The media info.

Public Methods

public boolean isReady (Activity activity)

Called before displaying but after the message is prepared.

Parameters
activity The current resumed activity.
Returns
  • true if the message is ready to be displayed, otherwise false.

public boolean onDisplay (Activity activity, boolean isRedisplay, DisplayHandler displayHandler)

Called to display an in-app message. The display handler's requestDisplayLock(Activity) must be called during `onStart()` in either the activity or fragment, and if the request is denied must immediately dismiss the component without any other calls to the display handler. Once the activity or fragment is finished being displayed call finished(ResolutionInfo).

Parameters
activity The current resumed activity.
isRedisplay true If the in-app message is being redisplayed, otherwise false.
displayHandler The display handler.
Returns
  • true if the in-app message was able to be displayed, otherwise false to try again later.

public void onFinish ()

Called after the in-app message is finished displaying. Perform any cache clean up here.

public int onPrepare (Context context)

Called before onDisplay(Activity, boolean, DisplayHandler) to prepare the message to be displayed.

Parameters
context The application context.
Returns
  • OK if the in-app message is ready to be displayed, RETRY if the message was unable to be prepared and needs to be retried, or CANCEL if the message was unable to be prepared and should be canceled.

Protected Methods

protected int cacheMedia (Context context, MediaInfo mediaInfo)

Caches the media info.

Parameters
context The application context.
mediaInfo The media info.
Returns
  • OK if the media was null, did not contain a cacheable resource, or if the resource was cached. RETRY if it failed to cache the resource.

protected void createCache (Context context)

Creates the cache.

Parameters
context The application context.
Throws
IOException If the cache fails to create.

protected InAppMessageCache getCache ()

Gets the cache.

Returns
  • The cache.

protected InAppMessage getMessage ()

Gets the in-app message.

Returns
  • The in-app message.