1 package com.bumptech.glide.load.resource.transcode; 2 3 import android.content.Context; 4 import android.graphics.Bitmap; 5 6 import com.bumptech.glide.load.engine.Resource; 7 import com.bumptech.glide.load.resource.drawable.GlideDrawable; 8 9 /** 10 * A wrapper for {@link com.bumptech.glide.load.resource.transcode.GlideBitmapDrawableTranscoder} that transcodes 11 * to {@link com.bumptech.glide.load.resource.drawable.GlideDrawable} rather than 12 * {@link com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable}. 13 * 14 * TODO: use ? extends GlideDrawable rather than GlideDrawable directly and remove this class. 15 */ 16 public class BitmapToGlideDrawableTranscoder implements ResourceTranscoder<Bitmap, GlideDrawable> { 17 18 private final GlideBitmapDrawableTranscoder glideBitmapDrawableTranscoder; 19 20 public BitmapToGlideDrawableTranscoder(Context context) { 21 this(new GlideBitmapDrawableTranscoder(context)); 22 } 23 24 public BitmapToGlideDrawableTranscoder(GlideBitmapDrawableTranscoder glideBitmapDrawableTranscoder) { 25 this.glideBitmapDrawableTranscoder = glideBitmapDrawableTranscoder; 26 } 27 28 @SuppressWarnings("unchecked") 29 @Override 30 public Resource<GlideDrawable> transcode(Resource<Bitmap> toTranscode) { 31 return (Resource<GlideDrawable>) (Resource<? extends GlideDrawable>) 32 glideBitmapDrawableTranscoder.transcode(toTranscode); 33 } 34 35 @Override 36 public String getId() { 37 return glideBitmapDrawableTranscoder.getId(); 38 } 39 } 40