~singpolyma/cheogram-android

7e5c69c3cc0807a351dce6b97a6d7243309b50d0 — Stephen Paul Weber 8 months ago e494462
drawDrawable should at least not crash when it has no idea how big
1 files changed, 7 insertions(+), 1 deletions(-)

M src/main/java/eu/siacs/conversations/persistance/FileBackend.java
M src/main/java/eu/siacs/conversations/persistance/FileBackend.java => src/main/java/eu/siacs/conversations/persistance/FileBackend.java +7 -1
@@ 1311,7 1311,13 @@ public class FileBackend {
            if (bitmap != null) return bitmap;
        }

        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Rect bounds = drawable.getBounds();
        int width = drawable.getIntrinsicWidth();
        if (width < 1) width = bounds == null || bounds.right < 1 ? 256 : bounds.right;
        int height = drawable.getIntrinsicHeight();
        if (height < 1) height = bounds == null || bounds.bottom < 1 ? 256 : bounds.bottom;

        bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);