From 30411ae1a42e46d0e5a2da494a39ed2767ba8808 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Thu, 29 Sep 2022 11:21:10 -0700 Subject: [PATCH] Replace Toast with Log.w on ReactImageView when null URL specified (#34819) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/34819 This is crashing on A12 because of using the regular Context instead of the application context. That said, this probably makes more sense as a log warning. Reviewed By: javache Differential Revision: D39852058 fbshipit-source-id: 1ac93f8cc9ecdb14f60baca175c8ecff2ff42ac0 --- .../src/main/java/com/facebook/react/views/image/BUCK | 1 + .../com/facebook/react/views/image/ReactImageView.java | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK index 0e2e0e4831ffbf..0c8b6134b45c12 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/BUCK @@ -65,6 +65,7 @@ rn_android_library( react_native_target("java/com/facebook/react/common:common"), react_native_target("java/com/facebook/react/module/annotations:annotations"), react_native_target("java/com/facebook/react/uimanager:uimanager"), + react_native_target("java/com/facebook/react/util:util"), react_native_target("java/com/facebook/react/modules/fresco:fresco"), react_native_target("java/com/facebook/react/uimanager/annotations:annotations"), react_native_target("java/com/facebook/react/views/imagehelper:withmultisource"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java index a118b9b607ab7f..5eb7a7febcf78b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java @@ -19,7 +19,6 @@ import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.widget.Toast; import androidx.annotation.Nullable; import com.facebook.common.internal.Objects; import com.facebook.common.references.CloseableReference; @@ -51,6 +50,7 @@ import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.UIManagerHelper; import com.facebook.react.uimanager.events.EventDispatcher; +import com.facebook.react.util.RNLog; import com.facebook.react.views.imagehelper.ImageSource; import com.facebook.react.views.imagehelper.MultiSourceHelper; import com.facebook.react.views.imagehelper.MultiSourceHelper.MultiSourceResult; @@ -597,11 +597,9 @@ private boolean shouldResize(ImageSource imageSource) { private void warnImageSource(String uri) { if (ReactBuildConfig.DEBUG) { - Toast.makeText( - getContext(), - "Warning: Image source \"" + uri + "\" doesn't exist", - Toast.LENGTH_SHORT) - .show(); + RNLog.w( + (ReactContext) getContext(), + "ReactImageView: Image source \"" + uri + "\" doesn't exist"); } } }