chore(Android): make ImageLoader onLoaded's result nullable#4247
Merged
kligarski merged 1 commit intoJul 2, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Android ImageLoader helper to allow onLoaded to receive a nullable Drawable, so callers can still be notified when Fresco produces a null bitmap (e.g., preventing UI updates from being skipped when an icon fails to materialize as a bitmap).
Changes:
- Change
ImageLoader.loadImage/loadImageInternalcallback type from(Drawable) -> Unitto(Drawable?) -> Unit. - Call
onLoaded(null)when Fresco returns aCloseableStaticBitmapwith anullunderlying bitmap.
Comments suppressed due to low confidence (1)
android/src/main/java/com/swmansion/rnscreens/gamma/helpers/ImageLoader.kt:30
loadImagereturns early whenImageSource(...).getUri(context)is null, which means the callback is never invoked. Now thatonLoadedacceptsDrawable?, it should still be called (withnull) so callers waiting on the callback can proceed (matching the PR’s goal of not missingonLoaded).
onLoaded: (Drawable?) -> Unit,
) {
// Since image loading might happen on a background thread
// ref. https://frescolib.org/docs/intro-image-pipeline.html
// We should schedule rendering the result on the UI thread
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
59
to
+63
| if (bitmap != null) { | ||
| val drawable = bitmap.toDrawable(context.resources) | ||
| onLoaded(drawable) | ||
| } else { | ||
| onLoaded(null) |
Contributor
Author
There was a problem hiding this comment.
I don't want to introduce such changes now, we can maybe create an issue to look into the image loader in general.
Contributor
Author
There was a problem hiding this comment.
ImageLoader onLoaded's result nullableImageLoader onLoaded's result nullable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #4242. Ensures that
onLoadedcallback is called even if bitmap was null.Closes https://github.com/software-mansion/react-native-screens-labs/issues/1589.
Reasoning
E.g. in Stack v5 toolbar menu item implementation when update via view command contains icon, we delay updating the menu item until we load the image. We don't want to miss the onLoaded callback, otherwise we won't update the menu item at all.
Changes
onLoaded's result inImageLoader.loadImageandImageLoader.loadImageInternalnullableDrawable(Drawable?)Before & after - visual documentation
N/A
Test plan
Ensure that images still load in tabs, stack v5.
Checklist