Do not attempt to draw overlay on null bitmap

This commit is contained in:
Daniel Gultsch 2018-10-07 13:44:20 +02:00
parent 3dceb9d3ad
commit 284861de65
2 changed files with 3 additions and 2 deletions

View file

@ -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()) {

View file

@ -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);