Fix issue #697 - Media not displayed for instances that doe not support media sizes.

This commit is contained in:
Thomas 2022-12-29 17:22:10 +01:00
parent 3a87f65b33
commit 6ff29f3514

View file

@ -432,6 +432,8 @@ public class MediaHelper {
} }
int orientation = getImageOrientation(uri, context.getContentResolver()); int orientation = getImageOrientation(uri, context.getContentResolver());
int scaledImageSize = 1024; int scaledImageSize = 1024;
final int maxRetry = 3;
int retry = 0;
do { do {
FileOutputStream outputStream = new FileOutputStream(targetedFile); FileOutputStream outputStream = new FileOutputStream(targetedFile);
decodeBitmapInputStream = context.getContentResolver().openInputStream(uri); decodeBitmapInputStream = context.getContentResolver().openInputStream(uri);
@ -452,7 +454,8 @@ public class MediaHelper {
reorientedBitmap.compress(format, 100, outputStream); reorientedBitmap.compress(format, 100, outputStream);
reorientedBitmap.recycle(); reorientedBitmap.recycle();
scaledImageSize /= 2; scaledImageSize /= 2;
} while (targetedFile.length() > getMaxSize(targetedFile.length())); retry++;
} while (targetedFile.length() > getMaxSize(targetedFile.length()) && retry < maxRetry);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
if (decodeBitmapInputStream != null) { if (decodeBitmapInputStream != null) {