Class POBNetworkHandler
-
- All Implemented Interfaces:
public class POBNetworkHandlerClass to make a network call using Volley API. Note: Caching is disabled by default for all the network requests. By default, responses are delivered on the current thread (usually background). You can specify a custom thread executor for response delivery.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePOBNetworkHandler.POBNetworkListenerCallback interface for delivering parsed responses.
public interfacePOBNetworkHandler.POBNetworkResultListenerInterface definition to get Network Result notification
public interfacePOBNetworkHandler.POBImageNetworkListenerpublic interfacePOBNetworkHandler.POBNetworkRedirectListenerCallback interface for delivering redirection event of network API.
-
Field Summary
Fields Modifier and Type Field Description public final static StringTAGpublic POBThreadExecutorthreadExecutor
-
Constructor Summary
Constructors Constructor Description POBNetworkHandler()Constructor Creates the Network handler instance with current thread delivery (no thread switching). POBNetworkHandler(POBRequestQueue requestQueue)Constructor Creates the Network handler instance with current thread delivery (no thread switching). POBNetworkHandler(POBRequestQueue requestQueue, POBThreadExecutor threadExecutor)Constructor Creates the Network handler instance with custom thread executor.
-
Method Summary
Modifier and Type Method Description POBThreadExecutorgetThreadExecutor()Returns the thread executor used for response delivery. voidsendRequest(@NonNull() String url, @Nullable() String tag, POBNetworkHandler.POBNetworkListener<String> listener, @Nullable() POBNetworkHandler.POBNetworkRedirectListener redirectListener)Send the network request using the string URL. voidsendRequest(String url, String tag, POBNetworkHandler.POBNetworkListener<String> listener)Send the network request using the string URL. voidsendRequest(POBHttpRequest request, POBNetworkHandler.POBNetworkListener<String> listener)Send the network request using PubMatic's HTTP request object. voidsendJSONRequest(POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<JSONObject> listener)Send the network request using PubMatic's HTTP request object. voidsendJSONRequest(@NonNull() POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<JSONObject> listener, @Nullable() POBNetworkHandler.POBNetworkResultListener resultListener)Send the network request using PubMatic's HTTP request object. voidsendRequest(@Nullable() POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<String> listener, @Nullable() POBNetworkHandler.POBNetworkRedirectListener redirectListener)Send the network request using PubMatic's HTTP request object. voidsendRequest(@Nullable() POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<String> listener, @Nullable() POBNetworkHandler.POBNetworkRedirectListener redirectListener, @Nullable() POBNetworkHandler.POBNetworkResultListener networkResultListener)Send the network request using PubMatic's HTTP request object. voidsendImageRequest(@Nullable() POBImageRequest request, @Nullable() POBNetworkHandler.POBImageNetworkListener<String> listener)voidcancelRequest(@NonNull() String tag)Cancels all the request which are associated with given tag -
-
Constructor Detail
-
POBNetworkHandler
POBNetworkHandler()
Constructor Creates the Network handler instance with current thread delivery (no thread switching).
-
POBNetworkHandler
POBNetworkHandler(POBRequestQueue requestQueue)
Constructor Creates the Network handler instance with current thread delivery (no thread switching).- Parameters:
requestQueue- request queue
-
POBNetworkHandler
POBNetworkHandler(POBRequestQueue requestQueue, POBThreadExecutor threadExecutor)
Constructor Creates the Network handler instance with custom thread executor.- Parameters:
requestQueue- request queuethreadExecutor- thread executor for response delivery
-
-
Method Detail
-
getThreadExecutor
@Nullable() POBThreadExecutor getThreadExecutor()
Returns the thread executor used for response delivery.
- Returns:
the thread executor, null if executing on current thread
-
sendRequest
void sendRequest(@NonNull() String url, @Nullable() String tag, POBNetworkHandler.POBNetworkListener<String> listener, @Nullable() POBNetworkHandler.POBNetworkRedirectListener redirectListener)
Send the network request using the string URL.
- Parameters:
url- String url for making network caltag- Request tag, it will be used in case of cancelling requestlistener- Notifies the success and failure eventsredirectListener- Notifies the redirect event i.
-
sendRequest
void sendRequest(String url, String tag, POBNetworkHandler.POBNetworkListener<String> listener)
Send the network request using the string URL.
- Parameters:
url- String url for making network calltag- request tag, it will be used in case of cancelling requestlistener- Notifies the success and failure events
-
sendRequest
void sendRequest(POBHttpRequest request, POBNetworkHandler.POBNetworkListener<String> listener)
Send the network request using PubMatic's HTTP request object.
- Parameters:
request- PubMatic's HTTP request object for making network calllistener- Notifies the success and failure events
-
sendJSONRequest
void sendJSONRequest(POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<JSONObject> listener)
Send the network request using PubMatic's HTTP request object. Call this method only when JSON response is expected.
- Parameters:
request- PubMatic's HTTP request object for making network calllistener- Notifies the success and failure events
-
sendJSONRequest
void sendJSONRequest(@NonNull() POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<JSONObject> listener, @Nullable() POBNetworkHandler.POBNetworkResultListener resultListener)
Send the network request using PubMatic's HTTP request object. Call this method only when JSON response is expected.
- Parameters:
request- PubMatic's HTTP request object for making network calllistener- Notifies the success and failure eventsresultListener- Notifies the network result before success or failure
-
sendRequest
void sendRequest(@Nullable() POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<String> listener, @Nullable() POBNetworkHandler.POBNetworkRedirectListener redirectListener)
Send the network request using PubMatic's HTTP request object.
- Parameters:
request- PubMatic's HTTP request object for making network calllistener- Notifies the success and failure eventsredirectListener- Notifies the redirect event i.
-
sendRequest
void sendRequest(@Nullable() POBHttpRequest request, @Nullable() POBNetworkHandler.POBNetworkListener<String> listener, @Nullable() POBNetworkHandler.POBNetworkRedirectListener redirectListener, @Nullable() POBNetworkHandler.POBNetworkResultListener networkResultListener)
Send the network request using PubMatic's HTTP request object.
- Parameters:
request- PubMatic's HTTP request object for making network calllistener- Notifies the success and failure eventsredirectListener- Notifies the redirect event i.
-
sendImageRequest
void sendImageRequest(@Nullable() POBImageRequest request, @Nullable() POBNetworkHandler.POBImageNetworkListener<String> listener)
-
cancelRequest
void cancelRequest(@NonNull() String tag)
Cancels all the request which are associated with given tag
- Parameters:
tag- String tag to cancel all associated requests
-
-
-
-