public interface

NetworkFetcher

com.facebook.imagepipeline.producers.NetworkFetcher<FETCH_STATE extends com.facebook.imagepipeline.producers.FetchState>
Known Indirect Subclasses

Class Overview

Interface that specifies network fetcher used by the image pipeline.

It is strongly recommended that implementations use an Executor in their fetch(FETCH_STATE, NetworkFetcher.Callback) method to execute the network request on a different thread.

When the fetch from the network fails or is cancelled, the subclass is responsible for calling NetworkFetcher.Callback methods. If these are not called, the pipeline will not know that the image fetch has failed and the application may not behave properly.

Summary

Nested Classes
interface NetworkFetcher.Callback Callback used to inform the network fetch producer. 
Public Methods
abstract FETCH_STATE createFetchState(Consumer<EncodedImage> consumer, ProducerContext producerContext)
Creates a new instance of the FetchState-derived object used to store state.
abstract void fetch(FETCH_STATE fetchState, NetworkFetcher.Callback callback)
Initiates the network fetch and informs the producer when a response is received via the provided callback.
abstract Map<String, String> getExtraMap(FETCH_STATE fetchState, int byteSize)
Gets a map containing extra parameters to pass to the listeners.
abstract void onFetchCompletion(FETCH_STATE fetchState, int byteSize)
Called after the fetch completes.
abstract boolean shouldPropagate(FETCH_STATE fetchState)
Gets whether the intermediate results should be propagated.

Public Methods

public abstract FETCH_STATE createFetchState (Consumer<EncodedImage> consumer, ProducerContext producerContext)

Creates a new instance of the FetchState-derived object used to store state.

Parameters
consumer the consumer
producerContext the producer's context
Returns
  • a new fetch state instance

public abstract void fetch (FETCH_STATE fetchState, NetworkFetcher.Callback callback)

Initiates the network fetch and informs the producer when a response is received via the provided callback.

Parameters
fetchState the fetch-specific state
callback the callback used to inform the network fetch producer

public abstract Map<String, String> getExtraMap (FETCH_STATE 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 abstract void onFetchCompletion (FETCH_STATE 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

public abstract boolean shouldPropagate (FETCH_STATE fetchState)

Gets whether the intermediate results should be propagated.

In addition to the requirements of this method, intermediate results are throttled so that a maximum of one every 100 ms is propagated. This is to conserve CPU and other resources.

Not applicable if progressive rendering is disabled or not supported for this image.

Parameters
fetchState the fetch-specific state
Returns
  • whether the intermediate results should be propagated