diff --git a/src/org/wordpress/android/WordPress.java b/src/org/wordpress/android/WordPress.java index c752e8a7e4ff..928ccb4bb9cb 100644 --- a/src/org/wordpress/android/WordPress.java +++ b/src/org/wordpress/android/WordPress.java @@ -598,11 +598,9 @@ public void onTrimMemory(final int level) { background = false; } - //Levels that we need to consider are TRIM_MEMORY_UI_HIDDEN = 20; - TRIM_MEMORY_RUNNING_CRITICAL = 15; - TRIM_MEMORY_RUNNING_LOW = 10; + //Levels that we need to consider are TRIM_MEMORY_RUNNING_CRITICAL = 15; - TRIM_MEMORY_RUNNING_LOW = 10; - TRIM_MEMORY_RUNNING_MODERATE = 5; if (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) { - int maxMemory = (int) (Runtime.getRuntime().freeMemory() / 1024); - int cacheSize = maxMemory / 16; - mBitmapCache.trimToSize(cacheSize); + mBitmapCache.evictAll(); } } diff --git a/src/org/wordpress/android/util/BitmapLruCache.java b/src/org/wordpress/android/util/BitmapLruCache.java index c6c00d385a53..fa18b33faf7c 100644 --- a/src/org/wordpress/android/util/BitmapLruCache.java +++ b/src/org/wordpress/android/util/BitmapLruCache.java @@ -2,7 +2,6 @@ package org.wordpress.android.util; import android.graphics.Bitmap; -import android.os.Build; import android.support.v4.util.LruCache; import com.android.volley.toolbox.ImageLoader.ImageCache; @@ -17,18 +16,8 @@ public BitmapLruCache(int maxSize) { protected int sizeOf(String key, Bitmap value) { // The cache size will be measured in kilobytes rather than // number of items. - - int bytes = 0; - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) { - bytes = (value.getRowBytes() * value.getHeight()); - } else { - bytes = value.getByteCount(); - } - - if (bytes!=0) - bytes = bytes / 1024; - - return bytes; + int bytes = (value.getRowBytes() * value.getHeight()); + return (bytes / 1024); //value.getByteCount() introduced in HONEYCOMB_MR1 or higher. } @Override @@ -40,4 +29,4 @@ public Bitmap getBitmap(String key) { public void putBitmap(String key, Bitmap bitmap) { this.put(key, bitmap); } -} +} \ No newline at end of file