@NonNull T transform( @NonNull Transformation<Bitmap> transformation, boolean isRequired) { if (isAutoCloneEnabled) { return clone().transform(transformation, isRequired); } DrawableTransformation drawableTransformation = new DrawableTransformation(transformation, isRequired); transform(Bitmap.class, transformation, isRequired); transform(Drawable.class, drawableTransformation, isRequired); // TODO: remove BitmapDrawable decoder and this transformation. // Registering as BitmapDrawable is simply an optimization to avoid some iteration and // isAssignableFrom checks when obtaining the transformation later on. It can be removed without // affecting the functionality. transform(BitmapDrawable.class, drawableTransformation.asBitmapDrawable(), isRequired); transform(GifDrawable.class, new GifDrawableTransformation(transformation), isRequired); return selfOrThrowIfLocked(); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); context = RuntimeEnvironment.application; Glide.init(context, new GlideBuilder().setBitmapPool(bitmapPool)); transformation = new GifDrawableTransformation(wrapped); }
@Test public void testEquals() throws NoSuchAlgorithmException { doAnswer(new Util.WriteDigest("first")).when(wrapped) .updateDiskCacheKey(isA(MessageDigest.class)); @SuppressWarnings("unchecked") Transformation<Bitmap> other = mock(Transformation.class); doAnswer(new Util.WriteDigest("other")).when(other) .updateDiskCacheKey(isA(MessageDigest.class)); keyTester .addEquivalenceGroup( transformation, new GifDrawableTransformation(wrapped), new GifDrawableTransformation(wrapped)) .addEquivalenceGroup(wrapped) .addEquivalenceGroup(new GifDrawableTransformation(other)) .addRegressionTest( new GifDrawableTransformation(wrapped), "a7937b64b8caa58f03721bb6bacf5c78cb235febe0e70b1b84cd99541461a08e") .test(); } }
public GifBitmapWrapperTransformation(BitmapPool bitmapPool, Transformation<Bitmap> bitmapTransformation) { this(bitmapTransformation, new GifDrawableTransformation(bitmapTransformation, bitmapPool)); }
private GifDrawableTransformation[] toGifTransformations(Transformation<Bitmap>[] bitmapTransformations) { GifDrawableTransformation[] transformations = new GifDrawableTransformation[bitmapTransformations.length]; for (int i = 0; i < bitmapTransformations.length; i++) { transformations[i] = new GifDrawableTransformation(bitmapTransformations[i], glide.getBitmapPool()); } return transformations; }