From b382210a658cda2a05fd7d5ad6175299a413c5e7 Mon Sep 17 00:00:00 2001 From: aleien Date: Sat, 20 Oct 2018 16:47:11 +0300 Subject: [PATCH] Updated BaseRequestOptions.transform api (update for issue #2875) --- .../RequestOptionsOverrideGenerator.java | 3 +- .../EmptyAppGlideModuleTest/GlideOptions.java | 11 +++++++ .../EmptyAppGlideModuleTest/GlideRequest.java | 14 +++++++++ .../MemoizeStaticMethod/GlideOptions.java | 11 +++++++ .../MemoizeStaticMethod/GlideRequest.java | 14 +++++++++ .../OverrideExtend/GlideOptions.java | 11 +++++++ .../OverrideExtend/GlideRequest.java | 14 +++++++++ .../GlideOptions.java | 11 +++++++ .../GlideRequest.java | 14 +++++++++ .../OverrideReplace/GlideOptions.java | 11 +++++++ .../OverrideReplace/GlideRequest.java | 14 +++++++++ .../SkipStaticMethod/GlideOptions.java | 11 +++++++ .../SkipStaticMethod/GlideRequest.java | 14 +++++++++ .../StaticMethodName/GlideOptions.java | 11 +++++++ .../StaticMethodName/GlideRequest.java | 14 +++++++++ .../GlideOptions.java | 11 +++++++ .../GlideRequest.java | 14 +++++++++ .../GlideOptions.java | 11 +++++++ .../resource/bitmap/TransformationUtils.java | 2 +- .../glide/request/BaseRequestOptions.java | 30 +++++++++++++++++++ .../glide/request/RequestOptionsTest.java | 2 +- 21 files changed, 245 insertions(+), 3 deletions(-) diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsOverrideGenerator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsOverrideGenerator.java index 065ac564fe..68cbdb6bd8 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsOverrideGenerator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsOverrideGenerator.java @@ -86,7 +86,8 @@ public String apply(ParameterSpec input) { .add(");\n") .build()); - if (methodToOverride.getSimpleName().toString().equals("transforms")) { + if (methodToOverride.getSimpleName().toString().contains("transform") + && methodToOverride.isVarArgs()) { result .addModifiers(Modifier.FINAL) .addAnnotation(SafeVarargs.class) diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java index b2cb067dc9..dea6e476fc 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -558,6 +559,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java index 440c153b72..42346164b9 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java @@ -384,9 +384,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java index 4da6ef1ba2..24e38fddb7 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -561,6 +562,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java index 18fb054fba..f3edeea929 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java @@ -384,9 +384,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java index 089b752ef8..48a2d8bd40 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -552,6 +553,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java index 860faf1acb..b15070a1b4 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java @@ -375,9 +375,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java index 89850adc88..0fe0aa379e 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -542,6 +543,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java index 0b3f59384d..f68d6f4764 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java @@ -375,9 +375,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java index 124b80a277..bd338d6373 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -552,6 +553,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java index 0c4f8ba9b9..f4d3bcaa31 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java @@ -375,9 +375,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java index a98146108f..1baed9ffa5 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -559,6 +560,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java index 18fb054fba..f3edeea929 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java @@ -384,9 +384,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java index 6c20113cba..32c1ab8b89 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -559,6 +560,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java index 18fb054fba..f3edeea929 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java @@ -384,9 +384,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java index ce0df8dd74..25d649038c 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -559,6 +560,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java index 51f731b2b7..95a2ffd7d6 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java @@ -384,9 +384,23 @@ public GlideRequest transform(@NonNull Transformation tra return (GlideRequest) super.transform(transformation); } + /** + * @see GlideOptions#transform(Transformation[]) + */ + @NonNull + @CheckResult + @SuppressWarnings({ + "unchecked", + "varargs" + }) + public GlideRequest transform(@NonNull Transformation... transformations) { + return (GlideRequest) super.transform(transformations); + } + /** * @see GlideOptions#transforms(Transformation[]) */ + @Deprecated @NonNull @CheckResult @SuppressWarnings({ diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java index 435ea9275f..bedefc889e 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java @@ -20,6 +20,7 @@ import com.bumptech.glide.request.RequestOptions; import java.lang.Class; import java.lang.Cloneable; +import java.lang.Deprecated; import java.lang.Override; import java.lang.SafeVarargs; import java.lang.SuppressWarnings; @@ -559,6 +560,16 @@ public GlideOptions transform(@NonNull Transformation transformation) { @SuppressWarnings("varargs") @NonNull @CheckResult + public final GlideOptions transform(@NonNull Transformation... transformations) { + return (GlideOptions) super.transform(transformations); + } + + @Override + @SafeVarargs + @SuppressWarnings("varargs") + @Deprecated + @NonNull + @CheckResult public final GlideOptions transforms(@NonNull Transformation... transformations) { return (GlideOptions) super.transforms(transformations); } diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java index 1c4d4812c0..fa0b17e40d 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java @@ -464,7 +464,7 @@ public static Bitmap roundedCorners( * *

This method does NOT resize the given {@link Bitmap}, it only rounds it's corners. * To both resize and round the corners of an image, consider - * {@link com.bumptech.glide.request.RequestOptions#transforms(Transformation[])} and/or + * {@link com.bumptech.glide.request.RequestOptions#transform(Transformation[])} and/or * {@link com.bumptech.glide.load.MultiTransformation}. * * @param inBitmap the source bitmap to use as a basis for the created bitmap. diff --git a/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java b/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java index 08136a3270..ea7f66fa44 100644 --- a/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java +++ b/library/src/main/java/com/bumptech/glide/request/BaseRequestOptions.java @@ -929,6 +929,36 @@ public T transform(@NonNull Transformation transformation) { @SuppressWarnings({"unchecked", "varargs", "CheckResult"}) @NonNull @CheckResult + public T transform(@NonNull Transformation... transformations) { + if (transformations.length > 1) { + return transform(new MultiTransformation<>(transformations), /*isRequired=*/ true); + } else if (transformations.length == 1) { + return transform(transformations[0]); + } else { + return selfOrThrowIfLocked(); + } + } + + /** + * Applies the given {@link Transformation}s in the given order for + * {@link Bitmap Bitmaps} to the default types ({@link Bitmap}, + * {@link android.graphics.drawable.BitmapDrawable}, and + * {@link com.bumptech.glide.load.resource.gif.GifDrawable}) + * and throws an exception if asked to transform an unknown type. + * + *

This will override previous calls to {@link #dontTransform()}. + * + * + * @deprecated Deprecated due to api update, use {@link #transform(Transformation[])} instead + * @param transformations One or more {@link Transformation}s for {@link Bitmap}s. + * @see #optionalTransform(Transformation) + * @see #optionalTransform(Class, Transformation) + */ + // Guaranteed to modify the current object by the isAutoCloneEnabledCheck. + @SuppressWarnings({"unchecked", "varargs", "CheckResult"}) + @NonNull + @CheckResult + @Deprecated public T transforms(@NonNull Transformation... transformations) { return transform(new MultiTransformation<>(transformations), /*isRequired=*/ true); } diff --git a/library/test/src/test/java/com/bumptech/glide/request/RequestOptionsTest.java b/library/test/src/test/java/com/bumptech/glide/request/RequestOptionsTest.java index 1f5536b3a2..48123faeb3 100644 --- a/library/test/src/test/java/com/bumptech/glide/request/RequestOptionsTest.java +++ b/library/test/src/test/java/com/bumptech/glide/request/RequestOptionsTest.java @@ -255,7 +255,7 @@ public void testApplyingDefaultOptions_withTransform_retrainsTransform() { @Test @SuppressWarnings({"unchecked", "varargs"}) public void testApplyMultiTransform() { - options.transforms(new CircleCrop(), new CenterCrop()); + options.transform(new CircleCrop(), new CenterCrop()); assertThat(options.isTransformationRequired()).isTrue(); assertThat(options.getTransformations()).containsKey(Bitmap.class); assertThat(options.getTransformations().get(Bitmap.class))