com.bumptech.glide.loader.stream
Interface StreamLoader

All Known Implementing Classes:
LocalUriLoader, VolleyStreamLoader

public interface StreamLoader

A base class for lazily and asynchronously opening an input stream that can be used to load an image. A new instance is created per image load by ModelLoader. loadStream may or may not be called for any given load depending on whether or not the corresponding image is cached. Cancel also may or may not be called.


Nested Class Summary
static interface StreamLoader.StreamReadyCallback
          An interface defining a callback for when an InputStream has been opened successfully or the load has failed because of an exception.
 
Method Summary
 void cancel()
          A method that will be called by an ImagePresenter when a load is no longer relevant (because we now want to load a different image into the view).
 void loadStream(StreamLoader.StreamReadyCallback cb)
          Asynchronously fetch and open an InputStream representing an image.
 

Method Detail

loadStream

void loadStream(StreamLoader.StreamReadyCallback cb)
Asynchronously fetch and open an InputStream representing an image. This will always be called on background thread so it is safe to perform long running tasks here. Any third party libraries called must be thread safe since this method will be called from a thread in a ExecutorService that may have more than one background thread. This method will only be called when the corresponding image is not in the cache.

Parameters:
cb - The callback to call when the load completes or fails due to an exception

cancel

void cancel()
A method that will be called by an ImagePresenter when a load is no longer relevant (because we now want to load a different image into the view). This method does not need to guarantee that any in process loads do not finish. It also may be called before a load starts or after it finishes. The best way to use this method is to cancel any loads that have not yet started, but allow those that are in process to finish since its we typically will want to display the same image in a different view in the near future.