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

com.octo.android.robospice.persistence.memory.BitmapLruCache Maven / Gradle / Ivy

The newest version!
package com.octo.android.robospice.persistence.memory;

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.os.Build;

/**
 * {@link LruCache} for {@link Bitmap}s.
 * @author David Stemmer
 * @author Mike Jancola
 * @author SNI
 */
public class BitmapLruCache extends LruCache> {
    public BitmapLruCache(int maxSize) {
        super(maxSize);
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
    @Override
    protected int sizeOf(Object key, CacheItem value) {
        Bitmap data = value.getData();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
            return data.getRowBytes() * data.getHeight();
        } else {
            return data.getByteCount();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy