public class

OkHttpNetworkFetcher

extends BaseNetworkFetcher<FETCH_STATE extends FetchState>
java.lang.Object
   ↳ com.facebook.imagepipeline.producers.BaseNetworkFetcher<FETCH_STATE extends com.facebook.imagepipeline.producers.FetchState>
     ↳ com.facebook.imagepipeline.backends.okhttp3.OkHttpNetworkFetcher

Class Overview

Network fetcher that uses OkHttp 3 as a backend.

Summary

Nested Classes
class OkHttpNetworkFetcher.OkHttpNetworkFetchState  
Public Constructors
OkHttpNetworkFetcher(OkHttpClient okHttpClient)
OkHttpNetworkFetcher(Call.Factory callFactory, Executor cancellationExecutor)
OkHttpNetworkFetcher(Call.Factory callFactory, Executor cancellationExecutor, boolean disableOkHttpCache)
Public Methods
OkHttpNetworkFetcher.OkHttpNetworkFetchState createFetchState(Consumer<EncodedImage> consumer, ProducerContext context)
void fetch(OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, NetworkFetcher.Callback callback)
Map<String, String> getExtraMap(OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, int byteSize)
Gets a map containing extra parameters to pass to the listeners.
void onFetchCompletion(OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, int byteSize)
Called after the fetch completes.
Protected Methods
void fetchWithRequest(OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, NetworkFetcher.Callback callback, Request request)
[Expand]
Inherited Methods
From class com.facebook.imagepipeline.producers.BaseNetworkFetcher
From class java.lang.Object
From interface com.facebook.imagepipeline.producers.NetworkFetcher

Public Constructors

public OkHttpNetworkFetcher (OkHttpClient okHttpClient)

Parameters
okHttpClient client to use

public OkHttpNetworkFetcher (Call.Factory callFactory, Executor cancellationExecutor)

Parameters
callFactory custom Call.Factory for fetching image from the network
cancellationExecutor executor on which fetching cancellation is performed if cancellation is requested from the UI Thread

public OkHttpNetworkFetcher (Call.Factory callFactory, Executor cancellationExecutor, boolean disableOkHttpCache)

Parameters
callFactory custom Call.Factory for fetching image from the network
cancellationExecutor executor on which fetching cancellation is performed if cancellation is requested from the UI Thread
disableOkHttpCache true if network requests should not be cached by OkHttp

Public Methods

public Map<String, String> getExtraMap (OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, int byteSize)

Gets a map containing extra parameters to pass to the listeners.

Returning map is optional and is useful for instrumentation purposes.

This map won't be modified by the caller.

Parameters
fetchState the fetch-specific state
byteSize size of the data in bytes
Returns
  • a map with extra parameters

public void onFetchCompletion (OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, int byteSize)

Called after the fetch completes.

Implementing this method is optional and is useful for instrumentation purposes.

Parameters
fetchState the fetch-specific state
byteSize size of the data in bytes

Protected Methods

protected void fetchWithRequest (OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, NetworkFetcher.Callback callback, Request request)