From 59a50b5f04a01a382d13a6ae9edaf56fa028356c Mon Sep 17 00:00:00 2001 From: Mats01-fer <82266507+Mats01-fer@users.noreply.github.com> Date: Tue, 24 Jan 2023 15:54:17 +0100 Subject: [PATCH] fix(android): Handle Null case when reading orientation (#456) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit e4e239c374e6ac74f095f060ae3e0e4fcb925ee7 Author: Mats01 <“matej.butkovic@gmail.com”> Date: Wed Jan 18 21:00:40 2023 +0100 add isnull orientation check commit ed312f6d53e109691d586bd00c21597426b2a7ae Author: Mats01 <“matej.butkovic@gmail.com”> Date: Wed Jan 18 17:16:17 2023 +0100 add check if rotation was read commit 6a156435ba31bcdd3bd3f4aa846f0d9bb2f11fbe Author: Mats01 <“matej.butkovic@gmail.com”> Date: Fri Jan 13 14:29:09 2023 +0100 return whitespace to original state commit 87f268c957e0348893ef1b576f1de10a006e3a68 Author: Mats01 <“matej.butkovic@gmail.com”> Date: Fri Jan 13 14:03:05 2023 +0100 update readme commit ff328f581ce4720541741f18ebf0e43d0698ba6e Author: Mats01 <“matej.butkovic@gmail.com”> Date: Fri Jan 13 14:00:42 2023 +0100 reverse witdh-height on andorid if orientation indicates rotation commit 89dd22831dd1d8f8fc7d362f2511cf8dd55ffa15 Author: Mats01 Date: Thu Jan 12 18:54:10 2023 +0100 add orientation to data return about image Co-authored-by: Mats01-fer <“matej.butkovic@gmail.com”> --- .../cameraroll/CameraRollModule.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java b/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java index e07c32e..18e598e 100644 --- a/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java +++ b/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java @@ -675,7 +675,11 @@ public class CameraRollModule extends ReactContextBaseJavaModule { } if (includeOrientation) { - image.putInt("orientation", media.getInt(orientationIndex)); + if(media.isNull(orientationIndex)) { + image.putInt("orientation", media.getInt(orientationIndex)); + } else { + image.putInt("orientation", 0); + } } else { image.putNull("orientation"); } @@ -827,11 +831,13 @@ public class CameraRollModule extends ReactContextBaseJavaModule { } - int orientation = media.getInt(orientationIndex); - if (orientation % 180 != 0) { - int temp = width; - width = height; - height = temp; + if(!media.isNull(orientationIndex)) { + int orientation = media.getInt(orientationIndex); + if (orientation >= 0 && orientation % 180 != 0) { + int temp = width; + width = height; + height = temp; + } } image.putInt("width", width);