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