|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sponsorpay.sdk.android.publisher.InterstitialLoader
public class InterstitialLoader
Performs the request for the interstitial in the background, notifies a registered listener of the results and shows
the InterstitialActivity
if and ad is returned.
Shows a progress dialog on top of the calling activity while it contacts the SponsorPayÕs servers to determine whether thereÕs an interstitial available.
If an ad is available, it will continue showing the loading progress dialog while the ad contents are loaded in the
background. The entire process must happen in less than 5 seconds (or a
custom amount of time that can be configured, see setLoadingTimeoutSecs(int)
). Otherwise a timeout error
will be triggered and the loading progress dialog will disappear without showing the ad.
When the contents of the ad finish loading, the loading progress view dialog will disappear and the interstitial will
be shown on the screen (by showing the InterstitialActivity
).
If no ad is available for this request, the loading progress dialog will disappear too and the process will be completed.
An InterstitialLoader.InterstitialLoadingStatusListener
can be defined which will be notified of interesting events in the life
of the interstitial.
Nested Class Summary | |
---|---|
class |
InterstitialLoader.InterstitialLoadingAsyncTask
Requests and loads an interstitial ad in the background. |
private class |
InterstitialLoader.InterstitialLoadingResults
Encloses the interesting data from the server's response to the interstitial request. |
static interface |
InterstitialLoader.InterstitialLoadingStatusListener
Interface to be implemented by parties interested in being notified of interesting events in the life of the interstitial. |
Field Summary | |
---|---|
private static java.lang.String |
INSTERSTITIAL_PRODUCTION_BASE_URL
|
private static java.lang.String |
INSTERSTITIAL_STAGING_BASE_URL
|
private static java.lang.String |
INTERSTITIAL_RESOURCES_PRODUCTION_BASE_URL
|
private static java.lang.String |
INTERSTITIAL_RESOURCES_STAGING_BASE_URL
|
private static int |
LOADING_TIMEOUT_SECONDS_DEFAULT
|
private java.lang.String |
mBackgroundUrl
|
private Activity |
mCallingActivity
The activity which created this InterstitialLoader instance. |
private java.lang.Runnable |
mCancelLoadingOnTimeOut
|
private Handler |
mHandler
|
private PublisherHostInfo |
mHostInfo
|
private static int |
MILLISECONDS_IN_SECOND
|
private InterstitialLoader.InterstitialLoadingAsyncTask |
mInterstitialLoadingAsyncTask
|
private InterstitialLoader.InterstitialLoadingStatusListener |
mLoadingStatusListener
|
private int |
mLoadingTimeoutSecs
|
private ProgressDialog |
mProgressDialog
Loading progress dialog. |
private boolean |
mShouldStayOpen
|
private java.lang.String |
mSkinName
|
private java.lang.String |
mUserId
|
private static boolean |
SHOULD_INTERSTITIAL_REMAIN_OPEN_DEFAULT
|
private static int |
sInterstitialAvailableResponseCount
Static counter which gets incremented every time an interstitial ad is returned. |
private static java.lang.String |
SKIN_NAME_DEFAULT
|
private static java.lang.String |
URL_PARAM_ALLOW_CAMPAIGN_KEY
|
private static java.lang.String |
URL_PARAM_ALLOW_CAMPAIGN_VALUE_ON
|
private static java.lang.String |
URL_PARAM_BACKGROUND_KEY
|
private static java.lang.String |
URL_PARAM_INTERSTITIAL_KEY
|
private static java.lang.String |
URL_PARAM_INTERSTITIAL_VALUE_ON
|
private static java.lang.String |
URL_PARAM_OFFSET_KEY
|
private static java.lang.String |
URL_PARAM_SKIN_KEY
|
Constructor Summary | |
---|---|
InterstitialLoader(Activity callingActivity,
java.lang.String userId,
PublisherHostInfo hostInfo,
InterstitialLoader.InterstitialLoadingStatusListener loadingStatusListener)
Initializes a new IntestitialLoader instance. |
Method Summary | |
---|---|
private void |
cancelInterstitialLoading()
Cancels the request and loading of the interstitial if the InterstitialActivity has still not been
launched. |
private static java.lang.String |
extractResponseString(HttpResponse pHttpResponse)
Utility method to extract the response string from an HTTP response. |
static boolean |
isInterstitialAvailableAccordingToStatusCode(int statusCode)
Takes an HTTP status code and returns whether it means that an interstitial ad is available. |
private void |
launchInterstitialActivity(InterstitialLoader.InterstitialLoadingResults result)
Launchs the InterstitialActivity with the initial contents of the interstitial ad, the initial base URL
for images, scripts and other dependencies, and the desired behavior for staying open after user redirection. |
protected void |
onInterstitialLoadResultsAvailable(InterstitialLoader.InterstitialLoadingResults result)
Called when the results of the interstitial request are available, i.e. |
void |
setBackgroundUrl(java.lang.String backgroundUrl)
Can be set to the absolute URL of an image to use as background graphic for the interstitial. |
void |
setLoadingTimeoutSecs(int loadingTimeoutSecs)
Sets the maximum amount of time the interstitial should take to load. |
void |
setShouldStayOpen(boolean shouldStayOpen)
Used to specify the behavior of the interstitial once the user clicks on the presented ad and is redirected outside the host publisher app. |
void |
setSkinName(java.lang.String skinName)
Used to specify the name of a custom skin or template for the requested interstitial. |
void |
startLoading()
Triggers the loading of the interstitial with the configured parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean SHOULD_INTERSTITIAL_REMAIN_OPEN_DEFAULT
private static final int LOADING_TIMEOUT_SECONDS_DEFAULT
private static final java.lang.String SKIN_NAME_DEFAULT
private static final java.lang.String INSTERSTITIAL_PRODUCTION_BASE_URL
private static final java.lang.String INSTERSTITIAL_STAGING_BASE_URL
private static final java.lang.String INTERSTITIAL_RESOURCES_PRODUCTION_BASE_URL
private static final java.lang.String INTERSTITIAL_RESOURCES_STAGING_BASE_URL
private static final java.lang.String URL_PARAM_INTERSTITIAL_KEY
private static final java.lang.String URL_PARAM_INTERSTITIAL_VALUE_ON
private static final java.lang.String URL_PARAM_ALLOW_CAMPAIGN_KEY
private static final java.lang.String URL_PARAM_ALLOW_CAMPAIGN_VALUE_ON
private static final java.lang.String URL_PARAM_SKIN_KEY
private static final java.lang.String URL_PARAM_OFFSET_KEY
private static final java.lang.String URL_PARAM_BACKGROUND_KEY
private static final int MILLISECONDS_IN_SECOND
private static int sInterstitialAvailableResponseCount
private Activity mCallingActivity
InterstitialActivity
and
to attach the loading progress dialog to.
private java.lang.String mUserId
private PublisherHostInfo mHostInfo
private InterstitialLoader.InterstitialLoadingStatusListener mLoadingStatusListener
private java.lang.String mBackgroundUrl
private java.lang.String mSkinName
private boolean mShouldStayOpen
private int mLoadingTimeoutSecs
private InterstitialLoader.InterstitialLoadingAsyncTask mInterstitialLoadingAsyncTask
private java.lang.Runnable mCancelLoadingOnTimeOut
private Handler mHandler
private ProgressDialog mProgressDialog
Constructor Detail |
---|
public InterstitialLoader(Activity callingActivity, java.lang.String userId, PublisherHostInfo hostInfo, InterstitialLoader.InterstitialLoadingStatusListener loadingStatusListener)
callingActivity
- The activity from which the loading of the interstitial is requested.userId
- The current user of the host application.hostInfo
- PublisherHostInfo
with information from the host device and publisher application.loadingStatusListener
- InterstitialLoader.InterstitialLoadingStatusListener
to register to be notified of events in the interstitial
lifecycle.Method Detail |
---|
public void setBackgroundUrl(java.lang.String backgroundUrl)
backgroundUrl
- public void setShouldStayOpen(boolean shouldStayOpen)
shouldStayOpen
- public void setSkinName(java.lang.String skinName)
skinName
- public void setLoadingTimeoutSecs(int loadingTimeoutSecs)
loadingTimeoutSecs
- public void startLoading()
Triggers the loading of the interstitial with the configured parameters.
The process will be performed in a background thread. The invocation of the
InterstitialLoader.InterstitialLoadingStatusListener
registered in
InterstitialLoader(Activity, String, PublisherHostInfo, InterstitialLoadingStatusListener)
will be done
in the calling thread.
private void cancelInterstitialLoading()
InterstitialActivity
has still not been
launched. Will dismiss the loading progress dialog if it is currently being shown.
protected void onInterstitialLoadResultsAvailable(InterstitialLoader.InterstitialLoadingResults result)
InterstitialLoader.InterstitialLoadingStatusListener
registered by the host publisher application of
the events "Will Show Interstitial", "Interstitial Request Error" and "No Interstitial Available"
result
- a InterstitialLoader.InterstitialLoadingResults
containing the status code and the contents of the response.private void launchInterstitialActivity(InterstitialLoader.InterstitialLoadingResults result)
InterstitialActivity
with the initial contents of the interstitial ad, the initial base URL
for images, scripts and other dependencies, and the desired behavior for staying open after user redirection.
result
- private static java.lang.String extractResponseString(HttpResponse pHttpResponse)
public static boolean isInterstitialAvailableAccordingToStatusCode(int statusCode)
statusCode
- The HTTP status code as int.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |