From 6ff29f3514f065f92282a61a7a2de87d74639246 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 29 Dec 2022 17:22:10 +0100 Subject: [PATCH] Fix issue #697 - Media not displayed for instances that doe not support media sizes. --- .../main/java/app/fedilab/android/helper/MediaHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/fedilab/android/helper/MediaHelper.java b/app/src/main/java/app/fedilab/android/helper/MediaHelper.java index 8a45fdb0..352075b6 100644 --- a/app/src/main/java/app/fedilab/android/helper/MediaHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/MediaHelper.java @@ -432,6 +432,8 @@ public class MediaHelper { } int orientation = getImageOrientation(uri, context.getContentResolver()); int scaledImageSize = 1024; + final int maxRetry = 3; + int retry = 0; do { FileOutputStream outputStream = new FileOutputStream(targetedFile); decodeBitmapInputStream = context.getContentResolver().openInputStream(uri); @@ -452,7 +454,8 @@ public class MediaHelper { reorientedBitmap.compress(format, 100, outputStream); reorientedBitmap.recycle(); scaledImageSize /= 2; - } while (targetedFile.length() > getMaxSize(targetedFile.length())); + retry++; + } while (targetedFile.length() > getMaxSize(targetedFile.length()) && retry < maxRetry); } catch (Exception e) { e.printStackTrace(); if (decodeBitmapInputStream != null) {