Android Open Source - Android-ImageManager Memory Lru Image Cache






From Project

Back to project page Android-ImageManager.

License

The source code is released under:

Copyright (c) 2011 Felipe Lima Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softwa...

If you think the Android project Android-ImageManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.felipecsl.android.imaging;
//w  w  w .  j  a  v  a2s  . c o  m
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

import com.felipecsl.android.Utils;

public class MemoryLruImageCache extends LruCache<String, Bitmap> {

    private MemoryCacheEntryRemovedCallback onEntryRemovedCallback;

    public static interface MemoryCacheEntryRemovedCallback {
        void onEntryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue);
    }

    public MemoryLruImageCache(final int cacheSizeInKb) {
        super(cacheSizeInKb);
    }

    public void setEntryRemovedCallback(final MemoryCacheEntryRemovedCallback onEntryRemovedCallback) {
        this.onEntryRemovedCallback = onEntryRemovedCallback;
    }

    @Override
    protected int sizeOf(final String key, final Bitmap bitmap) {
        // The cache size will be measured in kilobytes rather than number of items.
        return Utils.getSizeInBytes(bitmap) / 1024;
    }

    @Override
    protected void entryRemoved(final boolean evicted, final String key, final Bitmap oldValue, final Bitmap newValue) {
        super.entryRemoved(evicted, key, oldValue, newValue);

        if (onEntryRemovedCallback != null) {
            onEntryRemovedCallback.onEntryRemoved(evicted, key, oldValue, newValue);
        }
    }
}




Java Source Code List

com.felipecsl.android.Utils.java
com.felipecsl.android.imaging.BitmapHttpClient.java
com.felipecsl.android.imaging.BitmapProcessor.java
com.felipecsl.android.imaging.CacheManager.java
com.felipecsl.android.imaging.CacheableDrawable.java
com.felipecsl.android.imaging.DiskLruImageCache.java
com.felipecsl.android.imaging.ImageManagerCallback.java
com.felipecsl.android.imaging.ImageManager.java
com.felipecsl.android.imaging.ImageResponseCache.java
com.felipecsl.android.imaging.ImageUtil.java
com.felipecsl.android.imaging.JobOptions.java
com.felipecsl.android.imaging.LoadedFrom.java
com.felipecsl.android.imaging.MemoryLruImageCache.java
com.felipecsl.android.imaging.ProcessorCallback.java
com.felipecsl.android.imaging.ScaleType.java
com.felipecsl.android.imaging.sample.ListAdapter.java
com.felipecsl.android.imaging.sample.MainActivity.java