All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bumptech.glide.load.resource.bitmap.BitmapDrawableResource Maven / Gradle / Ivy

Go to download

A fast and efficient image loading library for Android focused on smooth scrolling.

There is a newer version: 5.0.0-rc01
Show newest version
package com.bumptech.glide.load.resource.bitmap;

import android.graphics.drawable.BitmapDrawable;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.Initializable;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.drawable.DrawableResource;
import com.bumptech.glide.util.Util;

/**
 * A {@link com.bumptech.glide.load.engine.Resource} that wraps an {@link
 * android.graphics.drawable.BitmapDrawable}
 *
 * 

This class ensures that every call to {@link #get()}} always returns a new {@link * android.graphics.drawable.BitmapDrawable} to avoid rendering issues if used in multiple views and * is also responsible for returning the underlying {@link android.graphics.Bitmap} to the given * {@link com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool} when the resource is recycled. */ public class BitmapDrawableResource extends DrawableResource implements Initializable { private final BitmapPool bitmapPool; // Public API. @SuppressWarnings("WeakerAccess") public BitmapDrawableResource(BitmapDrawable drawable, BitmapPool bitmapPool) { super(drawable); this.bitmapPool = bitmapPool; } @NonNull @Override public Class getResourceClass() { return BitmapDrawable.class; } @Override public int getSize() { return Util.getBitmapByteSize(drawable.getBitmap()); } @Override public void recycle() { bitmapPool.put(drawable.getBitmap()); } @Override public void initialize() { drawable.getBitmap().prepareToDraw(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy