|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sponsorpay.sdk.android.advertiser.AdvertiserCallbackSender
public class AdvertiserCallbackSender
Runs in the background the Advertiser Callback HTTP request.
Nested Class Summary | |
---|---|
static interface |
AdvertiserCallbackSender.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 Advertiser API |
private static java.lang.String |
API_STAGING_RESOURCE_URL
|
private HostInfo |
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 AdvertiserCallbackSender.APIResultListener |
mListener
Registered listener for the result of the advertiser callback request. |
private boolean |
mWasAlreadySuccessful
True if the advertiser callback was sent and received a successful response in a previous invocation. |
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 |
SUCCESSFUL_ANSWER_RECEIVED_KEY
The key for encoding the parameter corresponding to whether a previous invocation of the advertiser callback had received a successful response. |
Constructor Summary | |
---|---|
AdvertiserCallbackSender(HostInfo hostInfo,
AdvertiserCallbackSender.APIResultListener listener)
Constructor. |
Method Summary | |
---|---|
protected java.lang.Boolean |
doInBackground(HostInfo... 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 |
setWasAlreadySuccessful(boolean value)
Set whether a previous invocation of the advertiser callback had received a successful response. |
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 SUCCESSFUL_ANSWER_RECEIVED_KEY
private HttpUriRequest mHttpRequest
private HttpResponse mHttpResponse
private HttpClient mHttpClient
private boolean mWasAlreadySuccessful
private AdvertiserCallbackSender.APIResultListener mListener
private HostInfo mHostInfo
Constructor Detail |
---|
public AdvertiserCallbackSender(HostInfo hostInfo, AdvertiserCallbackSender.APIResultListener listener)
Constructor. Sets the request callback listener and stores the host information.
SeeAdvertiserHostInfo
and AdvertiserCallbackSender.APIResultListener
.
hostInfo
- the host information for the given devicelistener
- the callback listenerMethod Detail |
---|
public void setWasAlreadySuccessful(boolean value)
public void trigger()
AdvertiserCallbackSender.APIResultListener
registered
through the constructor #AsyncAPICaller(AdvertiserHostInfo, APIResultListener)
will
be notified.
protected java.lang.Boolean doInBackground(HostInfo... 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
AdvertiserCallbackSender.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
AdvertiserCallbackSender.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 |