CustomTarget
A base Target for loading resources (android.graphics.Bitmap, Drawable etc) that are used outside of android.view.Views.
If you're loading a resource into a View, use into, a subclass of ImageViewTarget, or CustomViewTarget. Using this class to load resources into Views can prevent Glide from correctly cancelling any previous loads, which may result in incorrect images appearing in the view, especially in scrolling views like androidx.recyclerview.widget.RecyclerView.
You MUST implement onLoadCleared and ensure that all references to any resource passed into the target in onResourceReady are removed before onLoadCleared completes. Failing to do so can result in graphical corruption, crashes caused by recycled Bitmaps, and other undefined behavior. It is never safe to leave onLoadCleared unimplemented or empty. Even if you do not manually clear this Target, Glide may do so automatically after certain lifecycle events in androidx.fragment.app.Fragments and android.app.Activitys.
This class can only be used with SIZE_ORIGINAL or when the desired resource dimensions are known when the Target is created. If you'd like to run some asynchronous process and make full use of getSize and SizeReadyCallback, extend Target directly instead of using this class.
Parameters
The type of resource that will be loaded (e.g. Bitmap).
Constructors
CustomTarget
that will return the given width
and height
as the requested size (unless overridden by override in the request).