1package com.bumptech.glide.load.resource.bitmap; 2 3import android.graphics.drawable.BitmapDrawable; 4import com.bumptech.glide.load.engine.Resource; 5import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; 6import com.bumptech.glide.util.Util; 7 8public class BitmapDrawableResource extends Resource<BitmapDrawable> { 9 private BitmapDrawable drawable; 10 private BitmapPool bitmapPool; 11 12 public BitmapDrawableResource(BitmapDrawable drawable, BitmapPool bitmapPool) { 13 this.drawable = drawable; 14 this.bitmapPool = bitmapPool; 15 } 16 17 @Override 18 public BitmapDrawable get() { 19 return drawable; 20 } 21 22 @Override 23 public int getSize() { 24 return Util.getSize(drawable.getBitmap()); 25 } 26 27 @Override 28 protected void recycleInternal() { 29 bitmapPool.put(drawable.getBitmap()); 30 } 31} 32