Class BaseGlideUrlLoader<Model>

  • Type Parameters:
    Model - The type of the model.
    All Implemented Interfaces:
    ModelLoader<Model,​java.io.InputStream>

    public abstract class BaseGlideUrlLoader<Model>
    extends java.lang.Object
    implements ModelLoader<Model,​java.io.InputStream>
    A base class for loading data over http/https. Can be subclassed for use with any model that can be translated in to InputStream data.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      ModelLoader.LoadData<java.io.InputStream> buildLoadData​(Model model, int width, int height, Options options)
      Returns a ModelLoader.LoadData containing a DataFetcher required to decode the resource represented by this model, as well as a set of Keys that identify the data loaded by the DataFetcher as well as an optional list of alternate keys from which equivalent data can be loaded.
      protected java.util.List<java.lang.String> getAlternateUrls​(Model model, int width, int height, Options options)
      Returns a list of alternate urls for the given model, width, and height from which equivalent data can be obtained (usually the same image with the same aspect ratio, but in a larger size) as the primary url.
      protected Headers getHeaders​(Model model, int width, int height, Options options)
      Returns the headers for the given model and dimensions as a map of strings to sets of strings, or null if no headers should be added.
      protected abstract java.lang.String getUrl​(Model model, int width, int height, Options options)
      Returns a valid url http:// or https:// for the given model and dimensions as a string.
      • Methods inherited from class java.lang.Object

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

      • buildLoadData

        @Nullable
        public ModelLoader.LoadData<java.io.InputStream> buildLoadData​(@NonNull
                                                                       Model model,
                                                                       int width,
                                                                       int height,
                                                                       @NonNull
                                                                       Options options)
        Description copied from interface: ModelLoader
        Returns a ModelLoader.LoadData containing a DataFetcher required to decode the resource represented by this model, as well as a set of Keys that identify the data loaded by the DataFetcher as well as an optional list of alternate keys from which equivalent data can be loaded. The DataFetcher will not be used if the resource is already cached.

        Note - If no valid data fetcher can be returned (for example if a model has a null URL), then it is acceptable to return a null data fetcher from this method.

        Specified by:
        buildLoadData in interface ModelLoader<Model,​java.io.InputStream>
        Parameters:
        model - The model representing the resource.
        width - The width in pixels of the view or target the resource will be loaded into, or Target.SIZE_ORIGINAL to indicate that the resource should be loaded at its original width.
        height - The height in pixels of the view or target the resource will be loaded into, or Target.SIZE_ORIGINAL to indicate that the resource should be loaded at its original height.
      • getUrl

        protected abstract java.lang.String getUrl​(Model model,
                                                   int width,
                                                   int height,
                                                   Options options)
        Returns a valid url http:// or https:// for the given model and dimensions as a string.
        Parameters:
        model - The model.
        width - The width in pixels of the view/target the image will be loaded into.
        height - The height in pixels of the view/target the image will be loaded into.
      • getAlternateUrls

        protected java.util.List<java.lang.String> getAlternateUrls​(Model model,
                                                                    int width,
                                                                    int height,
                                                                    Options options)
        Returns a list of alternate urls for the given model, width, and height from which equivalent data can be obtained (usually the same image with the same aspect ratio, but in a larger size) as the primary url.

        Implementing this method allows Glide to fulfill requests for bucketed images in smaller bucket sizes using already cached data for larger bucket sizes.

        Parameters:
        width - The width in pixels of the view/target the image will be loaded into.
        height - The height in pixels of the view/target the image will be loaded into.
      • getHeaders

        @Nullable
        protected Headers getHeaders​(Model model,
                                     int width,
                                     int height,
                                     Options options)
        Returns the headers for the given model and dimensions as a map of strings to sets of strings, or null if no headers should be added.
        Parameters:
        model - The model.
        width - The width in pixels of the view/target the image will be loaded into.
        height - The height in pixels of the view/target the image will be loaded into.