@Test public void isScaleOnlyOrNoTransform_withBitmapTransformation_isFalse() { options.transform(transformation); assertThat(options.isScaleOnlyOrNoTransform()).isFalse(); options.optionalTransform(transformation); assertThat(options.isScaleOnlyOrNoTransform()).isFalse(); }
@Test public void isScaleOnlyOrNoTransform_withCustomTransformation_isFalse() { options.transform(Bitmap.class, transformation); assertThat(options.isScaleOnlyOrNoTransform()).isFalse(); options.optionalTransform(Bitmap.class, transformation); assertThat(options.isScaleOnlyOrNoTransform()).isFalse(); }
private RequestOptions scaleOnlyTransform( DownsampleStrategy strategy, Transformation<Bitmap> transformation, boolean isTransformationRequired) { RequestOptions result = isTransformationRequired ? transform(strategy, transformation) : optionalTransform(strategy, transformation); result.isScaleOnlyOrNoTransform = true; return result; }
@SuppressWarnings({"WeakerAccess", "CheckResult"}) final RequestOptions optionalTransform(DownsampleStrategy downsampleStrategy, Transformation<Bitmap> transformation) { if (isAutoCloneEnabled) { return clone().optionalTransform(downsampleStrategy, transformation); } downsample(downsampleStrategy); return optionalTransform(transformation); }
/** * Applies {@link CircleCrop} to all default types, and ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #optionalTransform(Transformation) * @see #circleCrop() */ @CheckResult public RequestOptions optionalCircleCrop() { return optionalTransform(DownsampleStrategy.CENTER_OUTSIDE, new CircleCrop()); }
/** * Applies {@link com.bumptech.glide.load.resource.bitmap.CenterCrop} to all default types, and * ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #optionalTransform(Class, Transformation) * @see #centerCrop() */ @CheckResult public RequestOptions optionalCenterCrop() { return optionalTransform(DownsampleStrategy.CENTER_OUTSIDE, new CenterCrop()); }
/** * Applies the given {@link Transformation} for * {@link Bitmap Bitmaps} to the default types ({@link Bitmap}, * {@link android.graphics.drawable.BitmapDrawable}, and ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()}. * * @param transformation Any {@link Transformation} for {@link Bitmap}s. * @see #transform(Transformation) * @see #transform(Class, Transformation) */ // Guaranteed to modify the current object by the isAutoCloneEnabledCheck. @SuppressWarnings("CheckResult") @CheckResult public RequestOptions optionalTransform(Transformation<Bitmap> transformation) { if (isAutoCloneEnabled) { return clone().optionalTransform(transformation); } optionalTransform(Bitmap.class, transformation); // TODO: remove BitmapDrawable decoder and this transformation. optionalTransform(BitmapDrawable.class, new BitmapDrawableTransformation(transformation)); return selfOrThrowIfLocked(); }
/** * Applies the given {@link Transformation} for * {@link Bitmap Bitmaps} to the default types ({@link Bitmap}, * {@link android.graphics.drawable.BitmapDrawable}, and * throws an exception if asked to transform an unknown type. * * <p>This will override previous calls to {@link #dontTransform()}. * * @param transformation Any {@link Transformation} for {@link Bitmap}s. * @see #optionalTransform(Transformation) * @see #optionalTransform(Class, Transformation) */ // Guaranteed to modify the current object by the isAutoCloneEnabledCheck. @SuppressWarnings("CheckResult") @CheckResult public RequestOptions transform(@NonNull Transformation<Bitmap> transformation) { if (isAutoCloneEnabled) { return clone().transform(transformation); } optionalTransform(transformation); isTransformationRequired = true; fields |= TRANSFORMATION_REQUIRED; 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 * throws an exception if asked to transform an unknown type. * * <p>This will override previous calls to {@link #dontTransform()}. * * @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"}) @CheckResult public RequestOptions transforms(@NonNull Transformation<Bitmap>... transformations) { if (isAutoCloneEnabled) { return clone().transforms(transformations); } optionalTransform(new MultiTransformation<>(transformations)); isTransformationRequired = true; fields |= TRANSFORMATION_REQUIRED; return selfOrThrowIfLocked(); }
/** * Applies the given {@link Transformation} for any decoded resource of * the given type and throws if asked to transform an unknown resource type. * * <p>This will override previous calls to {@link #dontTransform()}. * * @param resourceClass The type of resource to transform. * @param transformation The {@link Transformation} to apply. * @see #optionalTransform(Class, Transformation) */ // Guaranteed to modify the current object by the isAutoCloneEnabledCheck. @SuppressWarnings("CheckResult") @CheckResult public <T> RequestOptions transform( Class<T> resourceClass, Transformation<T> transformation) { if (isAutoCloneEnabled) { return clone().transform(resourceClass, transformation); } optionalTransform(resourceClass, transformation); isTransformationRequired = true; fields |= TRANSFORMATION_REQUIRED; return selfOrThrowIfLocked(); }
Transformation<T> transformation) { if (isAutoCloneEnabled) { return clone().optionalTransform(resourceClass, transformation);
final RequestOptions glide_options = new RequestOptions().fitCenter().optionalTransform(new RoundedCorners((int) dp2px(20)));
try final RequestOptions glide_options = new RequestOptions().fitCenter().optionalTransform(new RoundedCorners((int) dp2px(20)));
try final RequestOptions glide_options = new RequestOptions().fitCenter().optionalTransform(new RoundedCorners((int) dp2px(20)));
try final RequestOptions glide_options = new RequestOptions().fitCenter().optionalTransform(new RoundedCorners((int) dp2px(20)));
try final RequestOptions glide_options = new RequestOptions().fitCenter().optionalTransform(new RoundedCorners((int) dp2px(20)));