Java 类com.bumptech.glide.load.MultiTransformation 实例源码

项目:saarang-iosched    文件:GifBitmapWrapperTransformation.java   
@Override
public Resource<GifBitmapWrapper> transform(Resource<GifBitmapWrapper> resource, int outWidth, int outHeight) {
    Resource<Bitmap> bitmapResource = resource.get().getBitmapResource();
    if (bitmapResource != null) {
        Resource<Bitmap> transformed = wrapped.transform(bitmapResource, outWidth, outHeight);
        if (transformed != bitmapResource) {
            GifBitmapWrapper gifBitmap = new GifBitmapWrapper(transformed, null);
            return new GifBitmapWrapperResource(gifBitmap);
        }
    } else {
        //TODO: this should be pushed down into a GifData transformation?
        Resource<GifData> gifResource = resource.get().getGifResource();
        GifData gifData = gifResource.get();
        Transformation<Bitmap> newTransformation =
                new MultiTransformation<Bitmap>(gifData.getFrameTransformation(), wrapped);
        gifData.setFrameTransformation(newTransformation);
        return new GifBitmapWrapperResource(new GifBitmapWrapper(null, new GifDataResource(gifData)));
    }
    return resource;
}
项目:AppDevFestSudeste2015    文件:GifBitmapWrapperTransformation.java   
@Override
public Resource<GifBitmapWrapper> transform(Resource<GifBitmapWrapper> resource, int outWidth, int outHeight) {
    Resource<Bitmap> bitmapResource = resource.get().getBitmapResource();
    if (bitmapResource != null) {
        Resource<Bitmap> transformed = wrapped.transform(bitmapResource, outWidth, outHeight);
        if (transformed != bitmapResource) {
            GifBitmapWrapper gifBitmap = new GifBitmapWrapper(transformed, null);
            return new GifBitmapWrapperResource(gifBitmap);
        }
    } else {
        //TODO: this should be pushed down into a GifData transformation?
        Resource<GifData> gifResource = resource.get().getGifResource();
        GifData gifData = gifResource.get();
        Transformation<Bitmap> newTransformation =
                new MultiTransformation<Bitmap>(gifData.getFrameTransformation(), wrapped);
        gifData.setFrameTransformation(newTransformation);
        return new GifBitmapWrapperResource(new GifBitmapWrapper(null, new GifDataResource(gifData)));
    }
    return resource;
}
项目:devfestnorte-app    文件:GifBitmapWrapperTransformation.java   
@Override
public Resource<GifBitmapWrapper> transform(Resource<GifBitmapWrapper> resource, int outWidth, int outHeight) {
    Resource<Bitmap> bitmapResource = resource.get().getBitmapResource();
    if (bitmapResource != null) {
        Resource<Bitmap> transformed = wrapped.transform(bitmapResource, outWidth, outHeight);
        if (transformed != bitmapResource) {
            GifBitmapWrapper gifBitmap = new GifBitmapWrapper(transformed, null);
            return new GifBitmapWrapperResource(gifBitmap);
        }
    } else {
        //TODO: this should be pushed down into a GifData transformation?
        Resource<GifData> gifResource = resource.get().getGifResource();
        GifData gifData = gifResource.get();
        Transformation<Bitmap> newTransformation =
                new MultiTransformation<Bitmap>(gifData.getFrameTransformation(), wrapped);
        gifData.setFrameTransformation(newTransformation);
        return new GifBitmapWrapperResource(new GifBitmapWrapper(null, new GifDataResource(gifData)));
    }
    return resource;
}
项目:saarang-iosched    文件:GifBitmapWrapperTransformation.java   
@Override
public Resource<GifBitmapWrapper> transform(Resource<GifBitmapWrapper> resource, int outWidth, int outHeight) {
    Resource<Bitmap> bitmapResource = resource.get().getBitmapResource();
    if (bitmapResource != null) {
        Resource<Bitmap> transformed = wrapped.transform(bitmapResource, outWidth, outHeight);
        if (transformed != bitmapResource) {
            GifBitmapWrapper gifBitmap = new GifBitmapWrapper(transformed, null);
            return new GifBitmapWrapperResource(gifBitmap);
        }
    } else {
        //TODO: this should be pushed down into a GifData transformation?
        Resource<GifData> gifResource = resource.get().getGifResource();
        GifData gifData = gifResource.get();
        Transformation<Bitmap> newTransformation =
                new MultiTransformation<Bitmap>(gifData.getFrameTransformation(), wrapped);
        gifData.setFrameTransformation(newTransformation);
        return new GifBitmapWrapperResource(new GifBitmapWrapper(null, new GifDataResource(gifData)));
    }
    return resource;
}
项目:GitHub    文件:RequestOptionsTest.java   
@Test
@SuppressWarnings({"unchecked", "varargs"})
public void testApplyMultiTransform() {
  options.transforms(new CircleCrop(), new CenterCrop());
  assertThat(options.isTransformationRequired()).isTrue();
  assertThat(options.getTransformations()).containsKey(Bitmap.class);
  assertThat(options.getTransformations().get(Bitmap.class))
    .isInstanceOf(MultiTransformation.class);
}
项目:RendererRecyclerViewAdapter    文件:ForkViewRenderer.java   
@Override
public void bindView(@NonNull final ForkModel model, @NonNull final ForkViewHolder holder) {
    holder.name.setText(model.getName());

    final RequestOptions options = new RequestOptions();
    options.transform(new MultiTransformation(new BlurTransformation(25), new CircleCrop()));

    Glide.with(getContext())
            .asBitmap()
            .load(model.getAvatarUrl())
            .apply(options)
            .into(holder.avatar);
    holder.itemView.setOnClickListener(view -> mListener.onForkItemClicked(model));
}
项目:RendererRecyclerViewAdapter    文件:UserViewRenderer.java   
@Override
public void bindView(@NonNull final StargazerModel model, @NonNull final UserViewHolder holder) {
    holder.name.setText(model.getName());

    final RequestOptions options = new RequestOptions();
    options.transform(new MultiTransformation(new BlurTransformation(25), new CircleCrop()));

    Glide.with(getContext())
            .asBitmap()
            .load(model.getAvatarUrl())
            .apply(options)
            .into(holder.avatar);
}
项目:saarang-iosched    文件:GenericRequestBuilder.java   
@SuppressWarnings("unchecked")
private Transformation<ResourceType> getFinalTransformation() {
    switch (transformations.size()) {
        case 0:
            return Transformation.NONE;
        case 1:
            return transformations.get(0);
        default:
            return new MultiTransformation<ResourceType>(transformations);
    }
}
项目:AppDevFestSudeste2015    文件:GenericRequestBuilder.java   
@SuppressWarnings("unchecked")
private Transformation<ResourceType> getFinalTransformation() {
    switch (transformations.size()) {
        case 0:
            return Transformation.NONE;
        case 1:
            return transformations.get(0);
        default:
            return new MultiTransformation<ResourceType>(transformations);
    }
}
项目:devfestnorte-app    文件:GenericRequestBuilder.java   
@SuppressWarnings("unchecked")
private Transformation<ResourceType> getFinalTransformation() {
    switch (transformations.size()) {
        case 0:
            return Transformation.NONE;
        case 1:
            return transformations.get(0);
        default:
            return new MultiTransformation<ResourceType>(transformations);
    }
}
项目:saarang-iosched    文件:GenericRequestBuilder.java   
@SuppressWarnings("unchecked")
private Transformation<ResourceType> getFinalTransformation() {
    switch (transformations.size()) {
        case 0:
            return Transformation.NONE;
        case 1:
            return transformations.get(0);
        default:
            return new MultiTransformation<ResourceType>(transformations);
    }
}
项目:GitHub    文件:RequestOptions.java   
/**
 * 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.
 *
 * <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) {
  return transform(new MultiTransformation<>(transformations), /*isRequired=*/ true);
}