Android Open Source - VolleyCookie Lru Bitmap Cache






From Project

Back to project page VolleyCookie.

License

The source code is released under:

Apache License

If you think the Android project VolleyCookie 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 br.com.newagemobile.volleycookie;
// w  ww  .  ja va  2  s.  co m
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

import com.android.volley.toolbox.ImageLoader;

public class LruBitmapCache extends LruCache<String, Bitmap> implements
        ImageLoader.ImageCache {
    public static int getDefaultLruCacheSize() {
        final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
        final int cacheSize = maxMemory / 8;

        return cacheSize;
    }

    public LruBitmapCache() {
        this(getDefaultLruCacheSize());
    }

    public LruBitmapCache(int sizeInKiloBytes) {
        super(sizeInKiloBytes);
    }

    @Override
    protected int sizeOf(String key, Bitmap value) {
        return value.getRowBytes() * value.getHeight() / 1024;
    }

    @Override
    public Bitmap getBitmap(String url) {
        return get(url);
    }

    @Override
    public void putBitmap(String url, Bitmap bitmap) {
        put(url, bitmap);
    }
}




Java Source Code List

br.com.newagemobile.volleycookie.AppController.java
br.com.newagemobile.volleycookie.ApplicationTest.java
br.com.newagemobile.volleycookie.LruBitmapCache.java
br.com.newagemobile.volleycookie.PersistentCookieStore.java
br.com.newagemobile.volleycookie.SerializableCookie.java