Commit 9b6be8c8 authored by Geoffrey Métais's avatar Geoffrey Métais

No need to pass View as param of getFromResource

parent 4c105a7f
......@@ -183,11 +183,11 @@ public class VideoListAdapter extends ArrayAdapter<MediaWrapper>
if (thumbnail == null) {
// missing thumbnail
holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.CENTER);
thumbnail = BitmapCache.getFromResource(v, R.drawable.ic_cone_o);
thumbnail = BitmapCache.getFromResource(v.getResources(), R.drawable.ic_cone_o);
} else if (thumbnail.getWidth() == 1 && thumbnail.getHeight() == 1) {
// dummy thumbnail
holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.CENTER);
thumbnail = BitmapCache.getFromResource(v, R.drawable.ic_cone_o);
thumbnail = BitmapCache.getFromResource(v.getResources(), R.drawable.ic_cone_o);
} else
holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.FIT_CENTER);
......
......@@ -23,12 +23,12 @@ package org.videolan.vlc.util;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.support.v4.util.LruCache;
import android.util.Log;
import android.view.View;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.VLCApplication;
......@@ -136,14 +136,15 @@ public class BitmapCache {
mCachedBitmaps.clear();
}
public static Bitmap getFromResource(View v, int resId) {
public static Bitmap getFromResource(Resources res, int resId) {
BitmapCache cache = BitmapCache.getInstance();
Bitmap bitmap = cache.getBitmapFromMemCache(resId);
if (bitmap == null) {
BitmapFactory.Options options = new BitmapFactory.Options();
BitmapUtil.setInBitmap(options);
options.inMutable = true;
bitmap = BitmapFactory.decodeResource(v.getResources(), resId, options);
if (AndroidUtil.isHoneycombOrLater())
options.inMutable = true;
bitmap = BitmapFactory.decodeResource(res, resId, options);
cache.addBitmapToMemCache(resId, bitmap);
}
return bitmap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment