List of usage examples for android.app ActivityManager isLowRamDevice
public boolean isLowRamDevice()
From source file:com.silentcircle.contacts.ContactPhotoManagerNew.java
@TargetApi(Build.VERSION_CODES.KITKAT) public ContactPhotoManagerImplNew(Context context) { mContext = context;/*from ww w. j ava 2s . com*/ final ActivityManager am = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)); final float cacheSizeAdjustment = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) ? (am.isLowRamDevice() ? 0.5f : 1.0f) : 0.5f; final int bitmapCacheSize = (int) (cacheSizeAdjustment * BITMAP_CACHE_SIZE); mBitmapCache = new LruCache<Object, Bitmap>(bitmapCacheSize) { @Override protected int sizeOf(Object key, Bitmap value) { return value.getByteCount(); } @Override protected void entryRemoved(boolean evicted, Object key, Bitmap oldValue, Bitmap newValue) { if (DEBUG) dumpStats(); } }; final int holderCacheSize = (int) (cacheSizeAdjustment * HOLDER_CACHE_SIZE); mBitmapHolderCache = new LruCache<Object, BitmapHolder>(holderCacheSize) { @Override protected int sizeOf(Object key, BitmapHolder value) { return value.bytes != null ? value.bytes.length : 0; } @Override protected void entryRemoved(boolean evicted, Object key, BitmapHolder oldValue, BitmapHolder newValue) { if (DEBUG) dumpStats(); } }; mBitmapHolderCacheRedZoneBytes = (int) (holderCacheSize * 0.75); if (DEBUG) { Log.i(TAG, "Cache adj: " + cacheSizeAdjustment); Log.d(TAG, "Cache size: " + btk(mBitmapHolderCache.maxSize()) + " + " + btk(mBitmapCache.maxSize())); } mThumbnailSize = context.getResources().getDimensionPixelSize(R.dimen.contact_browser_list_item_photo_size); }