From 284861de656d946c8d9daeecc968a6ee58721664 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 7 Oct 2018 13:44:20 +0200 Subject: [PATCH] Do not attempt to draw overlay on null bitmap --- .../eu/siacs/conversations/persistance/DatabaseBackend.java | 2 +- .../java/eu/siacs/conversations/persistance/FileBackend.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index dd79e7c24..f14c02ea7 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -651,7 +651,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { SQLiteDatabase db = this.getReadableDatabase(); String where = Resolver.Result.DOMAIN + "=?"; String[] whereArgs = {domain}; - Cursor cursor = db.query(RESOLVER_RESULTS_TABLENAME, null, where, whereArgs, null, null, null); + final Cursor cursor = db.query(RESOLVER_RESULTS_TABLENAME, null, where, whereArgs, null, null, null); Resolver.Result result = null; if (cursor != null) { if (cursor.moveToFirst()) { diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index cad3789a8..ed3a6542c 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -252,7 +252,7 @@ public class FileBackend { drawOverlay(bitmap, paintOverlayBlack(bitmap) ? R.drawable.play_video_black : R.drawable.play_video_white, 0.75f); } else { bitmap = cropCenterSquare(attachment.getUri(), size); - if ("image/gif".equals(attachment.getMime())) { + if (bitmap != null && "image/gif".equals(attachment.getMime())) { Bitmap withGifOverlay = bitmap.copy(Bitmap.Config.ARGB_8888, true); drawOverlay(withGifOverlay, paintOverlayBlack(withGifOverlay) ? R.drawable.play_gif_black : R.drawable.play_gif_white, 1.0f); bitmap.recycle(); @@ -1030,6 +1030,7 @@ public class FileBackend { return cropCenterSquare(input, size); } } catch (FileNotFoundException | SecurityException e) { + Log.d(Config.LOGTAG,"unable to open file "+image.toString(), e); return null; } finally { close(is);