summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Koch <akoch@google.com>2013-01-14 09:37:37 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-01-14 09:37:37 -0800
commit707a71e39e8e3bf284422265b680b73a7c63debf (patch)
tree96fad01fd3c309105bac0d60fc23cd13a9d83d32
parent369da18ffb8686f66bcbe081419bd4b1aa31442c (diff)
parent4e2c2dba1ac50d6d51be1492dcabe87703522323 (diff)
downloadframeworks_base-707a71e39e8e3bf284422265b680b73a7c63debf.zip
frameworks_base-707a71e39e8e3bf284422265b680b73a7c63debf.tar.gz
frameworks_base-707a71e39e8e3bf284422265b680b73a7c63debf.tar.bz2
am 4e2c2dba: am 013e9259: am 7e421365: am 1a551b16: am 6f680f52: Displaying Bitmaps Efficiently Training - Change memory calculation
* commit '4e2c2dba1ac50d6d51be1492dcabe87703522323': Displaying Bitmaps Efficiently Training - Change memory calculation
-rw-r--r--docs/downloads/training/BitmapFun.zipbin430475 -> 430504 bytes
-rw-r--r--docs/html/training/displaying-bitmaps/cache-bitmap.jd15
2 files changed, 8 insertions, 7 deletions
diff --git a/docs/downloads/training/BitmapFun.zip b/docs/downloads/training/BitmapFun.zip
index c4ea7aa..882ce03 100644
--- a/docs/downloads/training/BitmapFun.zip
+++ b/docs/downloads/training/BitmapFun.zip
Binary files differ
diff --git a/docs/html/training/displaying-bitmaps/cache-bitmap.jd b/docs/html/training/displaying-bitmaps/cache-bitmap.jd
index 2a333cc..417ec5b 100644
--- a/docs/html/training/displaying-bitmaps/cache-bitmap.jd
+++ b/docs/html/training/displaying-bitmaps/cache-bitmap.jd
@@ -101,19 +101,20 @@ private LruCache&lt;String, Bitmap&gt; mMemoryCache;
&#64;Override
protected void onCreate(Bundle savedInstanceState) {
...
- // Get memory class of this device, exceeding this amount will throw an
- // OutOfMemory exception.
- final int memClass = ((ActivityManager) context.getSystemService(
- Context.ACTIVITY_SERVICE)).getMemoryClass();
+ // Get max available VM memory, exceeding this amount will throw an
+ // OutOfMemory exception. Stored in kilobytes as LruCache takes an
+ // int in its constructor.
+ final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
// Use 1/8th of the available memory for this memory cache.
- final int cacheSize = 1024 * 1024 * memClass / 8;
+ final int cacheSize = maxMemory / 8;
mMemoryCache = new LruCache&lt;String, Bitmap&gt;(cacheSize) {
&#64;Override
protected int sizeOf(String key, Bitmap bitmap) {
- // The cache size will be measured in bytes rather than number of items.
- return bitmap.getByteCount();
+ // The cache size will be measured in kilobytes rather than
+ // number of items.
+ return bitmap.getByteCount() / 1024;
}
};
...