|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sponsorpay.sdk.android.advertiser.AsyncAPICaller
public class AsyncAPICaller
Runs in the background the Advertiser Callback HTTP request.
Nested Class Summary | |
---|---|
static interface |
AsyncAPICaller.APIResultListener
Interface to be implemented by parties interested in the response from the SponsorPay server for the advertiser callback. |
Field Summary | |
---|---|
private static java.lang.String |
API_PRODUCTION_RESOURCE_URL
The API resource URL to contact when talking to the Sponsorpay Ad API |
private static java.lang.String |
API_STAGING_RESOURCE_URL
|
private static java.lang.String |
LANGUAGE_KEY
The language setting key for the callback URL parameter |
private AdvertiserHostInfo |
mHostInfo
Used to extract required information for the host application and device. |
private HttpClient |
mHttpClient
The HTTP client employed to call the Sponsorpay API |
private HttpUriRequest |
mHttpRequest
The HTTP request that will be executed to contact the API with the callback request |
private HttpResponse |
mHttpResponse
The response returned by the SponsorPay API |
private AsyncAPICaller.APIResultListener |
mListener
Registered listener for the result of the advertiser callback request. |
private static java.lang.String |
OFFER_ID_KEY
The offer ID key for the callback URL parameter |
private static java.lang.String |
OS_VERSION_KEY
The OS version key for the callback URL parameter |
private static java.lang.String |
PHONE_VERSION_KEY
The phone version key for the callback URL parameter |
private static java.lang.String |
PROGRAM_ID_KEY
|
private static int |
SUCCESFUL_HTTP_STATUS_CODE
HTTP status code that the response should have in order to determine that the API has been contacted successfully. |
private static java.lang.String |
UDID_KEY
The UDID key for the callback URL parameter |
Constructor Summary | |
---|---|
AsyncAPICaller(AdvertiserHostInfo hostInfo,
AsyncAPICaller.APIResultListener listener)
Constructor. |
Method Summary | |
---|---|
protected java.lang.Boolean |
doInBackground(AdvertiserHostInfo... params)
Method overridden from AsyncTask . |
protected void |
onPostExecute(java.lang.Boolean requestWasSuccessful)
This method is called by the Android AsyncTask implementation in the UI thread (or the thread which
invoked trigger() ) when doInBackground(AdvertiserHostInfo...) returns. |
void |
trigger()
Triggers the callback request that contacts the Sponsorpay Advertiser API. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int SUCCESFUL_HTTP_STATUS_CODE
private static final java.lang.String API_PRODUCTION_RESOURCE_URL
private static final java.lang.String API_STAGING_RESOURCE_URL
private static final java.lang.String UDID_KEY
private static final java.lang.String OFFER_ID_KEY
private static final java.lang.String PROGRAM_ID_KEY
private static final java.lang.String OS_VERSION_KEY
private static final java.lang.String PHONE_VERSION_KEY
private static final java.lang.String LANGUAGE_KEY
private HttpUriRequest mHttpRequest
private HttpResponse mHttpResponse
private HttpClient mHttpClient
private AsyncAPICaller.APIResultListener mListener
private AdvertiserHostInfo mHostInfo
Constructor Detail |
---|
public AsyncAPICaller(AdvertiserHostInfo hostInfo, AsyncAPICaller.APIResultListener listener)
Constructor. Sets the request callback listener and stores the host information.
SeeAdvertiserHostInfo
and AsyncAPICaller.APIResultListener
.
hostInfo
- the host information for the given devicelistener
- the callback listenerMethod Detail |
---|
public void trigger()
AsyncAPICaller.APIResultListener
registered through the constructor
AsyncAPICaller(AdvertiserHostInfo, APIResultListener)
will be notified.
protected java.lang.Boolean doInBackground(AdvertiserHostInfo... params)
Method overridden from AsyncTask
. Executed on a background thread, runs the API contact request.
Encodes the host information in the request URL, runs the request, waits for the response, parses its status code
and lets the UI thread receive the result and notify the registered AsyncAPICaller.APIResultListener
.
params
- Only one parameter of type AdvertiserHostInfo
is expected.
AsyncTask
implementation.protected void onPostExecute(java.lang.Boolean requestWasSuccessful)
AsyncTask
implementation in the UI thread (or the thread which
invoked trigger()
) when doInBackground(AdvertiserHostInfo...)
returns. It will invoke the
registered AsyncAPICaller.APIResultListener
requestWasSuccessful
- true if the response has a successful status code (equal to SUCCESFUL_HTTP_STATUS_CODE
).
false otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |