Package 

Class LocalUriFetcher

  • All Implemented Interfaces:
    com.mobwith.imgmodule.load.data.DataFetcher

    
    public abstract class LocalUriFetcher<T>
     implements DataFetcher<T>
                        

    A DataFetcher that uses an ContentResolver to load data from a pointing to a local resource.

    • Constructor Summary

      Constructors 
      Constructor Description
      LocalUriFetcher(ContentResolver contentResolver, Uri uri) Opens an input stream for a uri pointing to a local asset.
    • Method Summary

      Modifier and Type Method Description
      final void loadData(@NonNull() Priority priority, @NonNull() DataFetcher.DataCallback<out Object> callback) Fetch data from which a resource can be decoded.
      void cleanup() Cleanup or recycle any resources used by this data fetcher.
      void cancel() A method that will be called when a load is no longer relevant and has been cancelled.
      DataSource getDataSource() Returns the com.mobwith.imgmodule.load.DataSource this fetcher will return data from.
      • Methods inherited from class com.mobwith.imgmodule.load.data.DataFetcher

        getDataClass, loadData
      • Methods inherited from class java.lang.Object

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

      • LocalUriFetcher

        LocalUriFetcher(ContentResolver contentResolver, Uri uri)
        Opens an input stream for a uri pointing to a local asset.
        Parameters:
        contentResolver - Any ContentResolver.
        uri - A Uri pointing to a local asset.
    • Method Detail

      • loadData

         final void loadData(@NonNull() Priority priority, @NonNull() DataFetcher.DataCallback<out Object> callback)

        Fetch data from which a resource can be decoded.

        This will always be called on background thread so it is safe to perform long running taskshere. Any third party libraries called must be thread safe (or move the work to another thread)since this method will be called from a thread in a that may have more than one background thread. YouMUST use the DataCallback once the request is complete.

        You are free to move the fetch work to another thread and call the callback from there.

        This method will only be called when the corresponding resource is not in the cache.

        Note - this method will be run on a background thread so blocking I/O is safe.

        Parameters:
        priority - The priority with which the request should be completed.
        callback - The callback to use when the request is complete
      • cleanup

         void cleanup()

        Cleanup or recycle any resources used by this data fetcher. This method will be called in afinally block after the data provided by loadData has been decoded by the .

        Note - this method will be run on a background thread so blocking I/O is safe.

      • cancel

         void cancel()

        A method that will be called when a load is no longer relevant and has been cancelled. Thismethod does not need to guarantee that any in process loads do not finish. It also may becalled 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 allowthose that are in process to finish since its we typically will want to display the sameresource in a different view in the near future.

        Note - this method will be run on the main thread so it should not perform blockingoperations and should finish quickly.