|
||||||||||
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 | |
---|---|
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 |
INTERSTITIAL_PRODUCTION_BASE_URL
|
private static java.lang.String |
INTERSTITIAL_PRODUCTION_DOMAIN
|
private static java.lang.String |
INTERSTITIAL_STAGING_BASE_URL
|
private static java.lang.String |
INTERSTITIAL_STAGING_DOMAIN
|
private static int |
LOADING_TIMEOUT_SECONDS_DEFAULT
|
static java.lang.String |
LOG_TAG
|
private AsyncRequest |
mAsyncRequest
|
private java.lang.String |
mBackgroundUrl
|
private Activity |
mCallingActivity
The activity which created this InterstitialLoader instance. |
private java.lang.Runnable |
mCancelLoadingOnTimeOut
|
private Handler |
mHandler
|
private HostInfo |
mHostInfo
|
private static int |
MILLISECONDS_IN_SECOND
|
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_BACKGROUND_KEY
|
private static java.lang.String |
URL_PARAM_INTERSTITIAL_KEY
|
private static java.lang.String |
URL_PARAM_SKIN_KEY
|
Constructor Summary | |
---|---|
InterstitialLoader(Activity callingActivity,
java.lang.String userId,
HostInfo 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 void |
launchInterstitialActivity(AsyncRequest request)
Launches 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. |
void |
onAsyncRequestComplete(AsyncRequest request)
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 |
---|
public static final java.lang.String LOG_TAG
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 INTERSTITIAL_PRODUCTION_BASE_URL
private static final java.lang.String INTERSTITIAL_STAGING_BASE_URL
private static final java.lang.String INTERSTITIAL_PRODUCTION_DOMAIN
private static final java.lang.String INTERSTITIAL_STAGING_DOMAIN
private static final java.lang.String URL_PARAM_INTERSTITIAL_KEY
private static final java.lang.String URL_PARAM_SKIN_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 HostInfo mHostInfo
private InterstitialLoader.InterstitialLoadingStatusListener mLoadingStatusListener
private java.lang.String mBackgroundUrl
private java.lang.String mSkinName
private boolean mShouldStayOpen
private int mLoadingTimeoutSecs
private AsyncRequest mAsyncRequest
private java.lang.Runnable mCancelLoadingOnTimeOut
private Handler mHandler
private ProgressDialog mProgressDialog
Constructor Detail |
---|
public InterstitialLoader(Activity callingActivity, java.lang.String userId, HostInfo 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
- HostInfo
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, HostInfo, 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.
private void launchInterstitialActivity(AsyncRequest request)
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
- public void onAsyncRequestComplete(AsyncRequest request)
InterstitialLoader.InterstitialLoadingStatusListener
registered
by the host publisher application of the events "Will Show Interstitial",
"Interstitial Request Error" and "No Interstitial Available"
onAsyncRequestComplete
in interface AsyncRequest.ResultListener
result
- a InterstitialLoadingResults
containing the status code and the contents
of the response.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |