Back to project page cloudmine-android.
The source code is released under:
Copyright (c) 2012 CloudMine LLC, http://cloudmine.me Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software")...
If you think the Android project cloudmine-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cloudmine.api.rest; /*from w ww . java2s . c o m*/ import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import com.android.volley.toolbox.DiskBasedCache; import com.android.volley.toolbox.ImageLoader; import java.io.File; import java.nio.ByteBuffer; /** * <br> * Copyright CloudMine LLC. All rights reserved<br> * See LICENSE file included with SDK for details. */ public class DiskBitmapCache extends DiskBasedCache implements ImageLoader.ImageCache { public DiskBitmapCache(Context context) { this(context.getCacheDir()); } public DiskBitmapCache(File rootDirectory, int maxCacheSizeInBytes) { super(rootDirectory, maxCacheSizeInBytes); } public DiskBitmapCache(File cacheDir) { super(cacheDir); } public Bitmap getBitmap(String url) { final Entry requestedItem = get(url); if (requestedItem == null) return null; return BitmapFactory.decodeByteArray(requestedItem.data, 0, requestedItem.data.length); } public void putBitmap(String url, Bitmap bitmap) { final Entry entry = new Entry(); ByteBuffer buffer = ByteBuffer.allocate(getSizeInBytes(bitmap)); bitmap.copyPixelsToBuffer(buffer); entry.data = buffer.array(); put(url, entry); } //From: https://code.google.com/p/android-beryl/source/browse/beryl/src/org/beryl/app/AndroidVersion.java private static int getSizeInBytes(Bitmap bitmap) { return bitmap.getRowBytes() * bitmap.getHeight(); } }