Back to Fresco

SettableDataSource

docs/javadoc/reference/com/facebook/imagepipeline/datasource/SettableDataSource.html

3.6.020.4 KB
Original Source

Fresco

|

|

Packages | Classes

Classes

Packages | Classes

Summary: Methods | Protected Methods | Inherited Methods | [Expand All]

public final class

SettableDataSource

extends AbstractDataSource<T>

| java.lang.Object | | ↳ | com.facebook.datasource.AbstractDataSource<T> | | | ↳ | com.facebook.imagepipeline.datasource.SettableDataSource<T> |

Class Overview

A DataSource whose result may be set by a #set(CloseableReference) or setException(Throwable) call. It may also be closed.

This data source has no intermediate results - calling #set(CloseableReference) means that the data source is finished.

Summary

Public Methods
static <V> SettableDataSource<V>
Creates a new SettableDataSource
CloseableReference<T>
Gets the result if any, null otherwise.
boolean
Sets the value of this data source.
boolean
Sets the data source to having failed with the given exception.
boolean
Sets the progress.
Protected Methods
void
Subclasses should override this method to close the result that is not needed anymore.

| [Expand] Inherited Methods | | --- | | From class com.facebook.datasource.AbstractDataSource

| boolean | close() Cancels the ongoing request and releases all associated resources. | | void | closeResult(T result) Subclasses should override this method to close the result that is not needed anymore. | | static AbstractDataSource.DataSourceInstrumenter | getDataSourceInstrumenter() | | Map<String, Object> | getExtras() | | synchronized Throwable | getFailureCause() | | synchronized float | getProgress() | | synchronized T | getResult() The most recent result of the asynchronous computation. | | synchronized boolean | hasFailed() | | boolean | hasMultipleResults() | | synchronized boolean | hasResult() | | synchronized boolean | isClosed() | | synchronized boolean | isFinished() | | void | notifyDataSubscriber(DataSubscriber<T> dataSubscriber, Executor executor, boolean isFailure, boolean isCancellation) | | void | notifyProgressUpdate() | | static void | provideInstrumenter(AbstractDataSource.DataSourceInstrumenter dataSourceInstrumenter) | | void | setExtras(Map<String, Object> extras) | | boolean | setFailure(Throwable throwable) Subclasses should invoke this method to set the failure. | | boolean | setFailure(Throwable throwable, Map<String, Object> extras) | | boolean | setProgress(float progress) Subclasses should invoke this method to set the progress. | | boolean | setResult(T value, boolean isLast, Map<String, Object> extras) Subclasses should invoke this method to set the result to value. | | boolean | setResult(T value, boolean isLast) | | void | subscribe(DataSubscriber<T> dataSubscriber, Executor executor) Subscribe for notifications whenever the state of the DataSource changes. |

| | From class java.lang.Object

| Object | clone() | | boolean | equals(Object arg0) | | void | finalize() | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |

| | From interface com.facebook.datasource.DataSource

| abstract boolean | close() Cancels the ongoing request and releases all associated resources. | | abstract Map<String, Object> | getExtras() | | abstract Throwable | getFailureCause() | | abstract float | getProgress() | | abstract T | getResult() The most recent result of the asynchronous computation. | | abstract boolean | hasFailed() | | abstract boolean | hasMultipleResults() | | abstract boolean | hasResult() | | abstract boolean | isClosed() | | abstract boolean | isFinished() | | abstract void | subscribe(DataSubscriber<T> dataSubscriber, Executor executor) Subscribe for notifications whenever the state of the DataSource changes. |

|

Public Methods

public static SettableDataSource<V> create()

Creates a new SettableDataSource

public CloseableReference<T> getResult()

Gets the result if any, null otherwise.

Value will be cloned and it's the caller's responsibility to close the returned value.

Returns
  • current best result

public boolean set(CloseableReference<T> valueRef)

Sets the value of this data source.

This method will return true if the value was successfully set, or false if the data source has already been set, failed or closed.

Passed CloseableReference is cloned, caller of this method still owns passed reference after the method returns.

Parameters

| valueRef | closeable reference to the value the data source should hold. |

Returns
  • true if the value was successfully set.

public boolean setException(Throwable throwable)

Sets the data source to having failed with the given exception.

This method will return true if the exception was successfully set, or false if the data source has already been set, failed or closed.

Parameters

| throwable | the exception the data source should hold. |

Returns
  • true if the exception was successfully set.

public boolean setProgress(float progress)

Sets the progress.

Parameters

| progress | the progress in range [0, 1] to be set. |

Returns
  • true if the progress was successfully set.

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

+Generated by Doclava. +