public class

PriorityNetworkFetcher

extends Object
implements NetworkFetcher<FETCH_STATE extends FetchState>
java.lang.Object
   ↳ com.facebook.imagepipeline.producers.PriorityNetworkFetcher<FETCH_STATE extends com.facebook.imagepipeline.producers.FetchState>

Class Overview

PriorityNetworkFetcher fetches images using a priority queue.

Fetches are delegated to another fetcher.

  • Two queues are maintained, one for each priority.
  • High-priority images (e.g, on-screen) are handled FIFO or LIFO, depending on a flag.
  • Low-priority images (e.g., prefetches) are handled FIFO.
  • Dequeuing is done thusly:
    • If there's an enqueued hi-pri requests, and there are less than 'maxOutstandingHiPri' currently active downloads, it is dequeued; then,
    • If there's an enqueued low-pri requests, and there are less than 'maxOutstandingLowPri' currently active downloads, it is dequeued.
  • When a request's priority changes, it is taken out of the queue and re-enqueued according to the rules above.

Summary

Nested Classes
class PriorityNetworkFetcher.PriorityFetchState<FETCH_STATE extends FetchState>  
Fields
public static final String TAG
Public Constructors
PriorityNetworkFetcher(NetworkFetcher<FETCH_STATE> delegate, boolean isHiPriFifo, int maxOutstandingHiPri, int maxOutstandingLowPri)
PriorityNetworkFetcher(NetworkFetcher<FETCH_STATE> delegate, boolean isHiPriFifo, int maxOutstandingHiPri, int maxOutstandingLowPri, MonotonicClock clock)
Public Methods
PriorityFetchState<FETCH_STATE> createFetchState(Consumer<EncodedImage> consumer, ProducerContext producerContext)
Creates a new instance of the FetchState-derived object used to store state.
void fetch(PriorityFetchState<FETCH_STATE> fetchState, NetworkFetcher.Callback callback)
Map<String, String> getExtraMap(PriorityFetchState<FETCH_STATE> fetchState, int byteSize)
void onFetchCompletion(PriorityFetchState<FETCH_STATE> fetchState, int byteSize)
boolean shouldPropagate(PriorityFetchState<FETCH_STATE> fetchState)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.facebook.imagepipeline.producers.NetworkFetcher

Fields

public static final String TAG

Public Constructors

public PriorityNetworkFetcher (NetworkFetcher<FETCH_STATE> delegate, boolean isHiPriFifo, int maxOutstandingHiPri, int maxOutstandingLowPri)

Parameters
isHiPriFifo if true, hi-pri requests are dequeued in the order they were enqueued. Otherwise, they're dequeued in reverse order.

public PriorityNetworkFetcher (NetworkFetcher<FETCH_STATE> delegate, boolean isHiPriFifo, int maxOutstandingHiPri, int maxOutstandingLowPri, MonotonicClock clock)

Public Methods

public PriorityFetchState<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 void fetch (PriorityFetchState<FETCH_STATE> fetchState, NetworkFetcher.Callback callback)

public Map<String, String> getExtraMap (PriorityFetchState<FETCH_STATE> fetchState, int byteSize)

public void onFetchCompletion (PriorityFetchState<FETCH_STATE> fetchState, int byteSize)

public boolean shouldPropagate (PriorityFetchState<FETCH_STATE> fetchState)