public class

ListDataSource

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

Class Overview

Data source that wraps number of other data sources and waits until all of them are finished. After that each call to getResult() returns list of final results of wrapped data sources. Caller of getResult() is responsible for closing all each of the results separately.

This data source does not propagate intermediate results.

Summary

Protected Constructors
ListDataSource(DataSource[]<CloseableReference<T>> dataSources)
Public Methods
boolean close()
Cancels the ongoing request and releases all associated resources.
static <T> ListDataSource<T> create(DataSource...<CloseableReference<T>> dataSources)
synchronized List<CloseableReference<T>> getResult()
The most recent result of the asynchronous computation.
synchronized boolean hasResult()
[Expand]
Inherited Methods
From class com.facebook.datasource.AbstractDataSource
From class java.lang.Object
From interface com.facebook.datasource.DataSource

Protected Constructors

protected ListDataSource (DataSource[]<CloseableReference<T>> dataSources)

Public Methods

public boolean close ()

Cancels the ongoing request and releases all associated resources.

Subsequent calls to getResult() will return null.

Returns
  • true if the data source is closed for the first time

public static ListDataSource<T> create (DataSource...<CloseableReference<T>> dataSources)

public synchronized List<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

public synchronized boolean hasResult ()