Skip to content

Commit

Permalink
Fix #1369 - crash fix; crash fix when trying to import photo, reading…
Browse files Browse the repository at this point in the history
… EXIF (for rotation) and file is unavailable
  • Loading branch information
budowski committed Oct 24, 2024
1 parent cac8011 commit a2b57d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions iNaturalist/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
android:versionCode="616"
android:versionName="1.35.2">
android:versionCode="617"
android:versionName="1.35.3">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand Down
19 changes: 16 additions & 3 deletions iNaturalist/src/main/java/org/inaturalist/android/ImageUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.inaturalist.android;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
Expand Down Expand Up @@ -74,6 +75,13 @@ public class ImageUtils {

public static void blur(Context context, Bitmap image, ImageView imageView) {
if (null == image) return;
if (context == null) return;
if (context instanceof Activity) {
Activity activity = (Activity) context;
if (activity.isDestroyed() || activity.isFinishing()) {
return; // Avoid loading if activity is destroyed or finishing
}
}

Glide.with(context)
.asBitmap()
Expand Down Expand Up @@ -402,9 +410,14 @@ public static String resizeImage(Context context, String path, Uri photoUri, int


if (path != null) {
androidx.exifinterface.media.ExifInterface exif = new androidx.exifinterface.media.ExifInterface(path);
rotationDegrees = exif.getRotationDegrees();
Logger.tag(TAG).error("resizeImage: degrees: " + rotationDegrees);
try {
androidx.exifinterface.media.ExifInterface exif = new androidx.exifinterface.media.ExifInterface(path);
rotationDegrees = exif.getRotationDegrees();
Logger.tag(TAG).info("resizeImage: degrees: " + rotationDegrees);
} catch (Exception exc) {
Logger.tag(TAG).error("resizeImage: exception while reading rotation");
Logger.tag(TAG).error(exc);
}
}

if (photoUri != null) {
Expand Down

0 comments on commit a2b57d6

Please sign in to comment.