public class GifDrawableTransformation extends Object implements Transformation<GifDrawable>
Transformation
that wraps a transformation for a
Bitmap
and can apply it to every frame of any
GifDrawable
.CHARSET, STRING_CHARSET_NAME
Constructor and Description |
---|
GifDrawableTransformation(Context context,
Transformation<Bitmap> wrapped)
Deprecated.
|
GifDrawableTransformation(Transformation<Bitmap> wrapped) |
GifDrawableTransformation(Transformation<Bitmap> wrapped,
BitmapPool bitmapPool)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
For caching to work correctly, implementations must implement this method and
Transformation.hashCode() . |
int |
hashCode()
For caching to work correctly, implementations must implement this method and
Transformation.equals(Object) . |
Resource<GifDrawable> |
transform(Context context,
Resource<GifDrawable> resource,
int outWidth,
int outHeight)
Transforms the given resource and returns the transformed resource.
|
void |
updateDiskCacheKey(MessageDigest messageDigest)
Adds all uniquely identifying information to the given digest.
|
public GifDrawableTransformation(Transformation<Bitmap> wrapped)
@Deprecated public GifDrawableTransformation(Context context, Transformation<Bitmap> wrapped)
GifDrawableTransformation(Transformation)
.@Deprecated public GifDrawableTransformation(Transformation<Bitmap> wrapped, BitmapPool bitmapPool)
GifDrawableTransformation(Transformation)
public Resource<GifDrawable> transform(Context context, Resource<GifDrawable> resource, int outWidth, int outHeight)
Transformation
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, Transformation.equals(Object)
, Transformation.hashCode()
, and
Key.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.NONE
or make sure Key.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.
transform
in interface Transformation<GifDrawable>
context
- The Application contextresource
- The resource to transform.outWidth
- The width of the view or target the resource will be displayed in, or Target.SIZE_ORIGINAL
to indicate the
original resource width.outHeight
- The height of the view or target the resource will be displayed in, or Target.SIZE_ORIGINAL
to indicate the
original resource height.public boolean equals(Object o)
Transformation
Transformation.hashCode()
.equals
in interface Key
equals
in interface Transformation<GifDrawable>
equals
in class Object
public int hashCode()
Transformation
Transformation.equals(Object)
.hashCode
in interface Key
hashCode
in interface Transformation<GifDrawable>
hashCode
in class Object
public void updateDiskCacheKey(MessageDigest messageDigest)
Key
Note - Using MessageDigest.reset()
inside of this method will result
in undefined behavior.
updateDiskCacheKey
in interface Key