AdDescriptorType - Type of descriptor expected from POBCommunicator.POBCommunicatorListener callback.public class POBCommunicator<AdDescriptorType extends POBAdDescriptor> extends java.lang.Object implements POBNetworkHandler.POBNetworkListener<org.json.JSONObject>, POBResponseParsing.POBResponseParserListener<AdDescriptorType>, POBAdBuilding.POBAdBuilderListener<AdDescriptorType>, POBNetworkHandler.POBNetworkResultListener
POBRequestBuilding, makes network call using POBNetworkHandler,
parses response using POBResponseParsing and finally format the parsed response using the
POBAdBuilding instance.| Modifier and Type | Class and Description |
|---|---|
static interface |
POBCommunicator.POBCommunicatorListener<AdDescriptorType extends POBAdDescriptor>
Interface to get the callback from
POBCommunicator |
static interface |
POBCommunicator.POBErrorCustomisationListener
Interface definition provides error to be update by client class of the Communicator.
|
| Constructor and Description |
|---|
POBCommunicator(POBRequestBuilding requestBuilder,
POBResponseParsing responseParser,
POBAdBuilding<AdDescriptorType> adBuilder,
POBNetworkHandler networkHandler)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
adBuilderOnSuccess(POBAdResponse<AdDescriptorType> adDescriptor) |
void |
cancel()
Cancels any outstanding network call.
|
POBNetworkResult |
getNetworkResult()
To get network result of the request, this will available only after making request call
|
void |
onFailure(POBError error)
Called when request is failed
|
void |
onResult(POBNetworkResult result)
Notify network result before notifying success or failure
|
void |
onSuccess(org.json.JSONObject response)
Called when a response is received.
|
void |
parserOnError(POBError error)
Notifies with the error object when the parsing is failure
|
void |
parserOnSuccess(POBAdResponse<AdDescriptorType> adResponse)
Notifies with the parsed object when the parsing is success
|
void |
requestAd()
Request an ad.
|
void |
setListener(POBCommunicator.POBCommunicatorListener<AdDescriptorType> listener)
Sets the listener to get the callback
|
void |
setPOBErrorCustomisationListener(POBCommunicator.POBErrorCustomisationListener pobErrorCustomisationListener)
Set the custom error listener to get customised error, this can be implemented by the client class
to provide customized error to communicator.
|
public POBCommunicator(@NonNull
POBRequestBuilding requestBuilder,
@NonNull
POBResponseParsing responseParser,
@NonNull
POBAdBuilding<AdDescriptorType> adBuilder,
@NonNull
POBNetworkHandler networkHandler)
requestBuilder - POBRequestBuilding instance to forms the requestresponseParser - POBResponseParsing instance to parse responseadBuilder - POBAdBuilding instance to format the parsed responsenetworkHandler - POBNetworkHandler instance to make a network callpublic void setListener(POBCommunicator.POBCommunicatorListener<AdDescriptorType> listener)
listener - The listener object to get the callbackpublic void setPOBErrorCustomisationListener(@Nullable
POBCommunicator.POBErrorCustomisationListener pobErrorCustomisationListener)
pobErrorCustomisationListener - the reference of custom error listenerpublic void requestAd()
public void cancel()
public void adBuilderOnSuccess(@NonNull
POBAdResponse<AdDescriptorType> adDescriptor)
adBuilderOnSuccess in interface POBAdBuilding.POBAdBuilderListener<AdDescriptorType extends POBAdDescriptor>public void parserOnSuccess(@NonNull
POBAdResponse<AdDescriptorType> adResponse)
POBResponseParsing.POBResponseParserListenerparserOnSuccess in interface POBResponseParsing.POBResponseParserListener<AdDescriptorType extends POBAdDescriptor>adResponse - Instance of the response classpublic void parserOnError(@NonNull
POBError error)
POBResponseParsing.POBResponseParserListenerparserOnError in interface POBResponseParsing.POBResponseParserListener<AdDescriptorType extends POBAdDescriptor>error - Error instancepublic void onSuccess(@Nullable
org.json.JSONObject response)
POBNetworkHandler.POBNetworkListeneronSuccess in interface POBNetworkHandler.POBNetworkListener<org.json.JSONObject>response - of generic typepublic void onFailure(@NonNull
POBError error)
POBNetworkHandler.POBNetworkListeneronFailure in interface POBNetworkHandler.POBNetworkListener<org.json.JSONObject>error - Error objectpublic void onResult(@Nullable
POBNetworkResult result)
POBNetworkHandler.POBNetworkResultListeneronResult in interface POBNetworkHandler.POBNetworkResultListenerresult - the result to get network result@Nullable public POBNetworkResult getNetworkResult()