Package 

Class SettableDataSource

  • All Implemented Interfaces:
    com.facebook.datasource.DataSource

    @ThreadSafe() 
    public final class SettableDataSource<T extends Object>
    extends AbstractDataSource<CloseableReference<T>>
                        

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

    This data source has no intermediate results - calling set(CloseableReference<T>) means that the data source is finished. </T></T>

    • Method Summary

      Modifier and Type Method Description
      final Boolean set(CloseableReference<T> valueRef) Sets the value of this data source.
      final Boolean setException(Throwable throwable) Sets the data source to having failed with the given exception.
      Boolean setProgress(Float progress) Sets the progress.
      CloseableReference<T> getResult() Gets the result if any, null otherwise.
      • Methods inherited from class com.facebook.imagepipeline.datasource.SettableDataSource

        close, getExtras, getFailureCause, getProgress, hasFailed, hasMultipleResults, hasResult, isClosed, isFinished, notifyDataSubscriber, notifyProgressUpdate, setExtras, setFailure, setFailure, setResult, setResult, subscribe
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • set

         final 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.
      • setException

         final 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.
      • setProgress

         Boolean setProgress(Float progress)

        Sets the progress.

        Parameters:
        progress - the progress in range 0, 1 to be set.
      • getResult

         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.