Class POBCommunicator
-
- All Implemented Interfaces:
-
com.pubmatic.sdk.common.base.POBAdBuilding.POBAdBuilderListener,com.pubmatic.sdk.common.base.POBResponseParsing.POBResponseParserListener,com.pubmatic.sdk.common.network.POBNetworkHandler.POBNetworkListener,com.pubmatic.sdk.common.network.POBNetworkHandler.POBNetworkResultListener
public class POBCommunicator<AdDescriptorType extends POBAdDescriptor> implements POBNetworkHandler.POBNetworkListener<T>, POBResponseParsing.POBResponseParserListener<T>, POBAdBuilding.POBAdBuilderListener<T>, POBNetworkHandler.POBNetworkResultListener
Class to handle the communication between the network layer and the UI layer. It forms the request using POBRequestBuilding, makes network call using POBNetworkHandler, parses response using POBResponseParsing and finally format the parsed response using the POBAdBuilding instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePOBCommunicator.POBCommunicatorListenerInterface to get the callback from POBCommunicator
public interfacePOBCommunicator.POBErrorCustomisationListenerInterface definition provides error to be update by client class of the Communicator.
-
Field Summary
Fields Modifier and Type Field Description public POBNetworkResultnetworkResult
-
Constructor Summary
Constructors Constructor Description POBCommunicator(POBRequestBuilding requestBuilder, POBResponseParsing responseParser, POBAdBuilding<AdDescriptorType> adBuilder, POBNetworkHandler networkHandler)Constructor
-
Method Summary
Modifier and Type Method Description POBNetworkResultgetNetworkResult()To get network result of the request, this will available only after making request call voidsetListener(POBCommunicator.POBCommunicatorListener<AdDescriptorType> listener)Sets the listener to get the callback voidrequestAd()Request an ad. voidcancel()Cancels any outstanding network call. voidadBuilderOnSuccess(@NonNull() POBAdResponse<AdDescriptorType> adDescriptor)voidparserOnSuccess(@NonNull() POBAdResponse<AdDescriptorType> adResponse)Notifies with the parsed object when the parsing is success voidparserOnError(@NonNull() POBError error)Notifies with the error object when the parsing is failure voidonSuccess(@Nullable() JSONObject response)Called when a response is received. voidonFailure(@NonNull() POBError error)Called when request is failed voidonResult(@Nullable() POBNetworkResult result)Notify network result before notifying success or failure voidsetPOBErrorCustomisationListener(@Nullable() 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. -
-
Constructor Detail
-
POBCommunicator
POBCommunicator(POBRequestBuilding requestBuilder, POBResponseParsing responseParser, POBAdBuilding<AdDescriptorType> adBuilder, POBNetworkHandler networkHandler)
Constructor- Parameters:
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 call
-
-
Method Detail
-
getNetworkResult
@Nullable() POBNetworkResult getNetworkResult()
To get network result of the request, this will available only after making request call
- Returns:
the network result of the request
-
setListener
void setListener(POBCommunicator.POBCommunicatorListener<AdDescriptorType> listener)
Sets the listener to get the callback
- Parameters:
listener- The listener object to get the callback
-
requestAd
void requestAd()
Request an ad.
-
cancel
void cancel()
Cancels any outstanding network call.
-
adBuilderOnSuccess
void adBuilderOnSuccess(@NonNull() POBAdResponse<AdDescriptorType> adDescriptor)
-
parserOnSuccess
void parserOnSuccess(@NonNull() POBAdResponse<AdDescriptorType> adResponse)
Notifies with the parsed object when the parsing is success
- Parameters:
adResponse- Instance of the response class
-
parserOnError
void parserOnError(@NonNull() POBError error)
Notifies with the error object when the parsing is failure
- Parameters:
error- Error instance
-
onSuccess
void onSuccess(@Nullable() JSONObject response)
Called when a response is received.
- Parameters:
response- of generic type
-
onFailure
void onFailure(@NonNull() POBError error)
Called when request is failed
- Parameters:
error- Error object
-
onResult
void onResult(@Nullable() POBNetworkResult result)
Notify network result before notifying success or failure
- Parameters:
result- the result to get network result
-
setPOBErrorCustomisationListener
void setPOBErrorCustomisationListener(@Nullable() 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.
- Parameters:
pobErrorCustomisationListener- the reference of custom error listener
-
-
-
-