List of usage examples for android.graphics Bitmap getByteCount
public final int getByteCount()
From source file:com.serloman.imagecachedownloader.cache.LRUImageCache.java
public LRUImageCache(int maxMemory) { int cacheSize = maxMemory / 4; listeners = new ArrayList<EvictListener>(); mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override//from www. ja va2s . co m protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in kilobytes rather than number of items. return bitmap.getByteCount() / 1024; } @Override protected void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) { super.entryRemoved(evicted, key, oldValue, newValue); for (EvictListener listener : listeners) listener.imageEvicted(evicted, key, oldValue, newValue); } }; }
From source file:com.commonsware.android.bitmap.iss.BitmapFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private int byteCount(Bitmap b) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return (b.getAllocationByteCount()); }/*from ww w . j a va 2 s . co m*/ return (b.getByteCount()); }
From source file:org.appcelerator.titanium.util.TiBlobLruCache.java
@Override protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in kilobytes rather than // number of items. if (android.os.Build.VERSION.SDK_INT > TiC.API_LEVEL_HONEYCOMB) { return bitmap.getByteCount() / 1024; } else {//from ww w .j a v a2s. c o m return bitmap.getRowBytes() * bitmap.getHeight() / 1024; } }
From source file:org.jitsi.android.gui.util.DrawableCache.java
/** * Creates new instance of <tt>DrawableCache</tt>. *//*from ww w . jav a 2 s . co m*/ public DrawableCache() { // 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 = maxMemory / 8; cache = new LruCache<String, BitmapDrawable>(cacheSize) { @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override protected int sizeOf(String key, BitmapDrawable value) { Bitmap bmp = value.getBitmap(); int byteSize; if (AndroidUtils.hasAPI(Build.VERSION_CODES.HONEYCOMB_MR1)) { byteSize = bmp.getByteCount(); } else { byteSize = bmp.getRowBytes() * bmp.getHeight(); } return byteSize / 1024; } }; }
From source file:org.opensilk.music.artwork.cache.BitmapLruCache.java
@Override @TargetApi(Build.VERSION_CODES.KITKAT)/*from w w w . ja v a 2 s.c o m*/ protected int sizeOf(String key, Bitmap value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return value.getAllocationByteCount(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return value.getByteCount(); } else { return value.getRowBytes() * value.getHeight(); } }
From source file:hochschuledarmstadt.photostream_tools.adapter.LruBitmapCache.java
@Override protected int sizeOf(Integer key, Bitmap value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return value.getAllocationByteCount() / 1024; } else {/*from ww w. j a va2 s . c o m*/ return value.getByteCount() / 1024; } }
From source file:net.quduo.pixel.interfaces.android.common.ImageLoader.java
private ImageLoader() { // ???// w w w .j a v a 2 s.c o m int maxMemory = (int) Runtime.getRuntime().maxMemory(); // ???1/8 int cacheSize = maxMemory / 8; mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override protected int sizeOf(String key, Bitmap bitmap) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } else { return getByteCount(bitmap); } } }; }
From source file:cs.man.ac.uk.tavernamobile.utils.TavernaAndroid.java
/**** for testing purpose ****/ @Override/*from w w w .ja va 2 s . c om*/ public void onCreate() { // ACRA.init(this); super.onCreate(); // Get max available VM memory, // since exceeding this amount will throw an OutOfMemory exception. final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); // Use 1/8th of the available memory for this memory cache. final int cacheSize = maxMemory / 8; mImageCache = new LruCache<String, Bitmap>(cacheSize) { @Override protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in kilobytes return bitmap.getByteCount() / 1024; } }; mCache = new HashMap<String, Object>(); }
From source file:com.blogspot.codigogoogle.listloadingsamples.ImageLoaderListAdapter.java
public ImageLoaderListAdapter(Activity context, ArrayList<Map<String, String>> listItems) { this.context = context; this.listItems = listItems; mPlaceHolderBitmap = decodeSampledBitmapFromResource(context.getResources(), R.drawable.img_placeholder, 20, 20);//from w w w. jav a2 s . co m final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); final int cacheSize = maxMemory / 8; mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override protected int sizeOf(String key, Bitmap bitmap) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount() / 1024; } else { return bitmap.getRowBytes() * bitmap.getHeight() / 1024; } } }; }
From source file:org.videolan.vlc.RecommendationsService.java
private boolean doRecommendations() { mNotificationManager.cancelAll();/*w ww.ja va2s.c om*/ int id = 0; ArrayList<MediaWrapper> videoList = MediaLibrary.getInstance().getVideoItems(); if (Util.isListEmpty(videoList)) return false; Bitmap pic; Collections.shuffle(videoList); for (MediaWrapper mediaWrapper : videoList) { pic = mMediaDatabase.getPicture(mediaWrapper.getUri()); if (pic != null && pic.getByteCount() > 4 && mediaWrapper.getTime() == 0) { buildRecommendation(mediaWrapper, ++id, Notification.PRIORITY_DEFAULT); } if (id == MAX_RECOMMENDATIONS) break; } return true; }