Commit fd165128 authored by Geoffrey Métais's avatar Geoffrey Métais

BitmapUtil: Prevent NPE on app startup

parent b74887c6
...@@ -100,8 +100,8 @@ public class BitmapUtil { ...@@ -100,8 +100,8 @@ public class BitmapUtil {
private static Bitmap fetchPicture(MediaWrapper media) { private static Bitmap fetchPicture(MediaWrapper media) {
final BitmapCache cache = BitmapCache.getInstance(); final BitmapCache cache = BitmapCache.getInstance();
Bitmap picture = readCoverBitmap(media.getArtworkURL()); final Bitmap picture = readCoverBitmap(media.getArtworkURL());
cache.addBitmapToMemCache(media.getLocation(), picture); if (picture != null) cache.addBitmapToMemCache(media.getLocation(), picture);
return picture; return picture;
} }
...@@ -114,12 +114,12 @@ public class BitmapUtil { ...@@ -114,12 +114,12 @@ public class BitmapUtil {
} }
private static Bitmap readCoverBitmap(String path) { private static Bitmap readCoverBitmap(String path) {
if (path == null) if (path == null) return null;
return null; final Context ctx = VLCApplication.getAppContext();
Resources res = VLCApplication.getAppResources(); if (ctx == null) return null;
final Resources res = ctx.getResources();
String uri = Uri.decode(path); String uri = Uri.decode(path);
if (uri.startsWith("file://")) if (uri.startsWith("file://")) uri = uri.substring(7);
uri = uri.substring(7);
Bitmap cover = null; Bitmap cover = null;
BitmapFactory.Options options = new BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options();
int height = res.getDimensionPixelSize(R.dimen.grid_card_thumb_height); int height = res.getDimensionPixelSize(R.dimen.grid_card_thumb_height);
......
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