Class CustomTarget<T>

    • Constructor Summary

      Constructors 
      Constructor Description
      CustomTarget()
      Creates a new CustomTarget that will attempt to load the resource in its original size.
      CustomTarget​(int width, int height)
      Creates a new CustomTarget that will return the given width and height as the requested size (unless overridden by BaseRequestOptions.override(int) in the request).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Request getRequest()
      Retrieves the current request for this target, should not be called outside of Glide.
      void getSize​(SizeReadyCallback cb)
      A method to retrieve the size of this target.
      void onDestroy()
      Callback for when Fragment.onDestroy()} or Activity.onDestroy() is called.
      void onLoadFailed​(android.graphics.drawable.Drawable errorDrawable)
      A mandatory lifecycle callback that is called when a load fails.
      void onLoadStarted​(android.graphics.drawable.Drawable placeholder)
      A lifecycle callback that is called when a load is started.
      void onStart()
      Callback for when Fragment.onStart()} or Activity.onStart() is called.
      void onStop()
      Callback for when Fragment.onStop()} or Activity.onStop()} is called.
      void removeCallback​(SizeReadyCallback cb)
      Removes the given callback from the pending set if it's still retained.
      void setRequest​(Request request)
      Sets the current request for this target to retain, should not be called outside of Glide.
      • Methods inherited from class java.lang.Object

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

      • CustomTarget

        public CustomTarget()
        Creates a new CustomTarget that will attempt to load the resource in its original size.

        This constructor can cause very memory inefficient loads if the resource is large and can cause OOMs. It's provided as a convenience for when you'd like to specify dimensions with BaseRequestOptions.override(int). In all other cases, prefer CustomTarget(int, int).

      • CustomTarget

        public CustomTarget​(int width,
                            int height)
        Creates a new CustomTarget that will return the given width and height as the requested size (unless overridden by BaseRequestOptions.override(int) in the request).
        Parameters:
        width - The requested width (> 0, or == Target.SIZE_ORIGINAL).
        height - The requested height (> 0, or == Target.SIZE_ORIGINAL).
        Throws:
        java.lang.IllegalArgumentException - if width/height doesn't meet the requirement: > 0, or == Target.SIZE_ORIGINAL
    • Method Detail

      • onStart

        public void onStart()
        Description copied from interface: LifecycleListener
        Callback for when Fragment.onStart()} or Activity.onStart() is called.
        Specified by:
        onStart in interface LifecycleListener
      • onStop

        public void onStop()
        Description copied from interface: LifecycleListener
        Callback for when Fragment.onStop()} or Activity.onStop()} is called.
        Specified by:
        onStop in interface LifecycleListener
      • onDestroy

        public void onDestroy()
        Description copied from interface: LifecycleListener
        Callback for when Fragment.onDestroy()} or Activity.onDestroy() is called.
        Specified by:
        onDestroy in interface LifecycleListener
      • onLoadStarted

        public void onLoadStarted​(@Nullable
                                  android.graphics.drawable.Drawable placeholder)
        Description copied from interface: Target
        A lifecycle callback that is called when a load is started.

        Note - This may not be called for every load, it is possible for example for loads to fail before the load starts (when the model object is null).

        Note - This method may be called multiple times before any other lifecycle method is called. Loads can be paused and restarted due to lifecycle or connectivity events and each restart may cause a call here.

        Specified by:
        onLoadStarted in interface Target<T>
        Parameters:
        placeholder - The placeholder drawable to optionally show, or null.
      • onLoadFailed

        public void onLoadFailed​(@Nullable
                                 android.graphics.drawable.Drawable errorDrawable)
        Description copied from interface: Target
        A mandatory lifecycle callback that is called when a load fails.

        Note - This may be called before Target.onLoadStarted(android.graphics.drawable.Drawable) if the model object is null.

        You must ensure that any current Drawable received in Target.onResourceReady(Object, Transition) is no longer used before redrawing the container (usually a View) or changing its visibility.

        Specified by:
        onLoadFailed in interface Target<T>
        Parameters:
        errorDrawable - The error drawable to optionally show, or null.
      • getSize

        public final void getSize​(@NonNull
                                  SizeReadyCallback cb)
        Description copied from interface: Target
        A method to retrieve the size of this target.
        Specified by:
        getSize in interface Target<T>
        Parameters:
        cb - The callback that must be called when the size of the target has been determined
      • removeCallback

        public final void removeCallback​(@NonNull
                                         SizeReadyCallback cb)
        Description copied from interface: Target
        Removes the given callback from the pending set if it's still retained.
        Specified by:
        removeCallback in interface Target<T>
        Parameters:
        cb - The callback to remove.
      • setRequest

        public final void setRequest​(@Nullable
                                     Request request)
        Description copied from interface: Target
        Sets the current request for this target to retain, should not be called outside of Glide.
        Specified by:
        setRequest in interface Target<T>
      • getRequest

        @Nullable
        public final Request getRequest()
        Description copied from interface: Target
        Retrieves the current request for this target, should not be called outside of Glide.
        Specified by:
        getRequest in interface Target<T>