Skip to content

Commit

Permalink
Resolve issue #23816, updated with recent merges (#23961)
Browse files Browse the repository at this point in the history
Summary:
This fixes #23816, which states that `getSize()` does not function correctly on Android. The original PR for this is now outdated as there have been merges into master that would create merge conflicts.

[Android] [Fixed] - Added correct handling for `getSize()` to avoid warnings being thrown.import
Pull Request resolved: #23961

Differential Revision: D14505183

Pulled By: cpojer

fbshipit-source-id: 3d8976fd518de0903d7736a8cbd8371987eb1b2d
  • Loading branch information
RyanElliott10 authored and facebook-github-bot committed Mar 18, 2019
1 parent 68825f9 commit eec2495
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ rn_android_library(
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/modules/fresco:fresco"),
react_native_target("java/com/facebook/react/module/annotations:annotations"),
react_native_target("java/com/facebook/react/views/imagehelper:imagehelper"),
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.views.imagehelper.ImageSource;

@ReactModule(name = ImageLoaderModule.NAME)
public class ImageLoaderModule extends ReactContextBaseJavaModule implements
Expand Down Expand Up @@ -79,8 +80,8 @@ public void getSize(
return;
}

Uri uri = Uri.parse(uriString);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).build();
ImageSource source = new ImageSource(getReactApplicationContext(), uriString);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(source.getUri()).build();

DataSource<CloseableReference<CloseableImage>> dataSource =
Fresco.getImagePipeline().fetchDecodedImage(request, mCallerContext);
Expand Down Expand Up @@ -139,8 +140,8 @@ public void getSizeWithHeaders(
return;
}

Uri uri = Uri.parse(uriString);
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
ImageSource source = new ImageSource(getReactApplicationContext(), uriString);
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(source.getUri());
ImageRequest request = ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder, headers);

DataSource<CloseableReference<CloseableImage>> dataSource =
Expand Down

0 comments on commit eec2495

Please sign in to comment.