@Override public Resource<Drawable> transcode(Resource<GifBitmapWrapper> toTranscode) { GifBitmapWrapper gifBitmap = toTranscode.get(); Resource<Bitmap> bitmapResource = gifBitmap.getBitmapResource(); final Resource resource; final Drawable drawable; if (bitmapResource != null) { resource = bitmapResource; drawable = new BitmapDrawable(resources, bitmapResource.get()); } else { resource = gifBitmap.getGifResource(); drawable = gifBitmap.getGifResource().get().getDrawable(); } return new DrawableResource(drawable, resource); }
@Override public Resource<Drawable> decode(Drawable source, int width, int height) throws IOException { return new DrawableResource<Drawable>(source) { @Override public int getSize() { if (drawable instanceof BitmapDrawable) { return Util.getBitmapByteSize(((BitmapDrawable) drawable).getBitmap()); } else { return 1; } } @Override public void recycle() { } }; }
@Override public Resource<Drawable> decode(ApplicationInfo source, int width, int height) throws IOException { Drawable icon = context.getPackageManager().getApplicationIcon(source); return new DrawableResource<Drawable>(icon) { @Override public int getSize() { // best effort if (drawable instanceof BitmapDrawable) { return Util.getBitmapByteSize(((BitmapDrawable)drawable).getBitmap()); } else { return 1; } } @Override public void recycle() { /* not from our pool */ } }; }
@Override public Resource<Drawable> decode(Drawable source, int width, int height) throws IOException { return new DrawableResource<Drawable>(source) { @Override public int getSize() { return 1; } @Override public void recycle() { } }; }