Package com.swrve.sdk.messaging
Class SwrveMessage
- java.lang.Object
-
- com.swrve.sdk.messaging.SwrveMessage
-
- All Implemented Interfaces:
SwrveBaseMessage
public class SwrveMessage extends java.lang.Object implements SwrveBaseMessage
In-app message inside a campaign, with different formats.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.File
cacheDir
protected SwrveInAppCampaign
campaign
protected java.util.List<SwrveMessageFormat>
formats
protected int
id
protected java.lang.String
name
protected int
priority
-
Constructor Summary
Constructors Constructor Description SwrveMessage(SwrveInAppCampaign campaign, java.io.File cacheDir)
SwrveMessage(SwrveInAppCampaign campaign, org.json.JSONObject messageData, java.io.File cacheDir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areAssetsReady(java.util.Set<java.lang.String> assetsOnDisk, java.util.Map<java.lang.String,java.lang.String> properties)
protected boolean
assetInCache(java.util.Set<java.lang.String> assetsOnDisk, java.lang.String asset)
java.io.File
getCacheDir()
SwrveInAppCampaign
getCampaign()
SwrveMessageFormat
getFormat(com.swrve.sdk.messaging.SwrveOrientation orientation)
Search for a format with the given orientation.java.util.List<SwrveMessageFormat>
getFormats()
int
getId()
java.lang.String
getName()
int
getPriority()
protected void
setCacheDir(java.io.File cacheDir)
protected void
setCampaign(SwrveInAppCampaign campaign)
protected void
setFormats(java.util.List<SwrveMessageFormat> formats)
protected void
setId(int id)
protected void
setName(java.lang.String name)
void
setPriority(int priority)
boolean
supportsOrientation(com.swrve.sdk.messaging.SwrveOrientation orientation)
Returns true if the message has a format for the given orientation.
-
-
-
Field Detail
-
id
protected int id
-
name
protected java.lang.String name
-
priority
protected int priority
-
campaign
protected SwrveInAppCampaign campaign
-
formats
protected java.util.List<SwrveMessageFormat> formats
-
cacheDir
protected java.io.File cacheDir
-
-
Constructor Detail
-
SwrveMessage
public SwrveMessage(SwrveInAppCampaign campaign, java.io.File cacheDir)
-
SwrveMessage
public SwrveMessage(SwrveInAppCampaign campaign, org.json.JSONObject messageData, java.io.File cacheDir) throws org.json.JSONException
- Throws:
org.json.JSONException
-
-
Method Detail
-
getId
public int getId()
- Specified by:
getId
in interfaceSwrveBaseMessage
- Returns:
- the message id.
-
setId
protected void setId(int id)
-
getName
public java.lang.String getName()
- Returns:
- the message name.
-
setName
protected void setName(java.lang.String name)
-
getPriority
public int getPriority()
- Specified by:
getPriority
in interfaceSwrveBaseMessage
- Returns:
- the message priority.
-
setPriority
public void setPriority(int priority)
-
getFormats
public java.util.List<SwrveMessageFormat> getFormats()
- Returns:
- list of message formats for this device.
-
setFormats
protected void setFormats(java.util.List<SwrveMessageFormat> formats)
-
getCacheDir
public java.io.File getCacheDir()
- Returns:
- the directory where resources will be saved.
-
setCacheDir
protected void setCacheDir(java.io.File cacheDir)
-
getCampaign
public SwrveInAppCampaign getCampaign()
- Specified by:
getCampaign
in interfaceSwrveBaseMessage
- Returns:
- the related campaign.
-
setCampaign
protected void setCampaign(SwrveInAppCampaign campaign)
-
getFormat
public SwrveMessageFormat getFormat(com.swrve.sdk.messaging.SwrveOrientation orientation)
Search for a format with the given orientation.- Parameters:
orientation
- Portrait, Landscape or Both.- Returns:
- SwrveMessageFormat Message format for the specified orientation.
-
supportsOrientation
public boolean supportsOrientation(com.swrve.sdk.messaging.SwrveOrientation orientation)
Returns true if the message has a format for the given orientation.- Specified by:
supportsOrientation
in interfaceSwrveBaseMessage
- Parameters:
orientation
- A SwrveOrientation- Returns:
- true if the message supports the given orientation.
-
assetInCache
protected boolean assetInCache(java.util.Set<java.lang.String> assetsOnDisk, java.lang.String asset)
-
areAssetsReady
public boolean areAssetsReady(java.util.Set<java.lang.String> assetsOnDisk, java.util.Map<java.lang.String,java.lang.String> properties)
- Parameters:
assetsOnDisk
- Already downloaded assets on diskproperties
- properties, when applied are used to resolve the dynamic image urls that may occur- Returns:
- true if all assets for this message have been downloaded.
-
-