public class

CloseableProducerToDataSourceAdapter

extends AbstractProducerToDataSourceAdapter<T>
java.lang.Object
   ↳ com.facebook.datasource.AbstractDataSource<T>
     ↳ com.facebook.imagepipeline.datasource.AbstractProducerToDataSourceAdapter<T>
       ↳ com.facebook.imagepipeline.datasource.CloseableProducerToDataSourceAdapter<T>

Class Overview

DataSource> backed by a Producer>

Summary

Public Methods
static <T> DataSource<CloseableReference<T>> create(Producer<CloseableReference<T>> producer, SettableProducerContext settableProducerContext, RequestListener2 listener)
CloseableReference<T> getResult()
The most recent result of the asynchronous computation.
Protected Methods
void closeResult(CloseableReference<T> result)
Subclasses should override this method to close the result that is not needed anymore.
void onNewResultImpl(CloseableReference<T> result, int status, ProducerContext producerContext)
[Expand]
Inherited Methods
From class com.facebook.imagepipeline.datasource.AbstractProducerToDataSourceAdapter
From class com.facebook.datasource.AbstractDataSource
From class java.lang.Object
From interface com.facebook.datasource.DataSource
From interface com.facebook.imagepipeline.request.HasImageRequest

Public Methods

public static DataSource<CloseableReference<T>> create (Producer<CloseableReference<T>> producer, SettableProducerContext settableProducerContext, RequestListener2 listener)

public CloseableReference<T> getResult ()

The most recent result of the asynchronous computation.

The caller gains ownership of the object and is responsible for releasing it. Note that subsequent calls to getResult might give different results. Later results should be considered to be of higher quality.

This method will return null in the following cases:

  • when the DataSource does not have a result (hasResult returns false).
  • when the last result produced was null.

Returns
  • current best result

Protected Methods

protected void closeResult (CloseableReference<T> result)

Subclasses should override this method to close the result that is not needed anymore.

This method is called in two cases: 1. to clear the result when data source gets closed 2. to clear the previous result when a new result is set

protected void onNewResultImpl (CloseableReference<T> result, int status, ProducerContext producerContext)