Class UnitTransformation<T>
- Type Parameters:
T- The type of the resource that will always be returned unmodified.
- All Implemented Interfaces:
Key,Transformation<T>
-
Field Summary
Fields inherited from interface com.bumptech.glide.load.Key
CHARSET, STRING_CHARSET_NAME -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> UnitTransformation<T>get()Returns a UnitTransformation for the given type.Transforms the given resource and returns the transformed resource.voidupdateDiskCacheKey(MessageDigest messageDigest) Adds all uniquely identifying information to the given digest.
-
Method Details
-
get
Returns a UnitTransformation for the given type.- Type Parameters:
T- The type of the resource to be transformed.
-
transform
@NonNull public Resource<T> transform(@NonNull Context context, @NonNull Resource<T> resource, int outWidth, int outHeight) Description copied from interface:TransformationTransforms the given resource and returns the transformed resource.If the original resource object is not returned, the original resource will be recycled and it's internal resources may be reused. This means it is not safe to rely on the original resource or any internal state of the original resource in any new resource that is created. Usually this shouldn't occur, but if absolutely necessary either the original resource object can be returned with modified internal state, or the data in the original resource can be copied into the transformed resource.
If a Transformation is updated,
Key.equals(Object),Key.hashCode(), andKey.updateDiskCacheKey(java.security.MessageDigest)should all change. If you're using a simple String key an easy way to do this is to append a version number to your key. Failing to do so will mean users may see images loaded from cache that had the old version of the Transformation applied. Changing the return values of those methods will ensure that the cache key has changed and therefore that any cached resources will be re-generated using the updated Transformation.During development you may need to either using
DiskCacheStrategy.NONEor make sureKey.updateDiskCacheKey(java.security.MessageDigest)changes each time you make a change to the Transformation. Otherwise the resource you request may be loaded from disk cache and your Transformation may not be called.- Specified by:
transformin interfaceTransformation<T>- Parameters:
context- The Application contextresource- The resource to transform.outWidth- The width of the view or target the resource will be displayed in, orTarget.SIZE_ORIGINALto indicate the original resource width.outHeight- The height of the view or target the resource will be displayed in, orTarget.SIZE_ORIGINALto indicate the original resource height.- Returns:
- The transformed resource.
-
updateDiskCacheKey
Description copied from interface:KeyAdds all uniquely identifying information to the given digest.Note - Using
MessageDigest.reset()inside of this method will result in undefined behavior.- Specified by:
updateDiskCacheKeyin interfaceKey
-