mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Using wrapManagedObject in RCTImageManager instead of manual casting
Summary: Hiding casting madness and complexity behind a helper function to avoid bugs and improve maintainability. Reviewed By: sammy-SC Differential Revision: D17923549 fbshipit-source-id: 105891d85b0412fa4a17d7ae8a9e156fc1b151fb
This commit is contained in:
committed by
Facebook Github Bot
parent
b7c14f29cf
commit
14df0b2a78
@@ -9,6 +9,7 @@
|
||||
|
||||
#import <react/imagemanager/ImageResponse.h>
|
||||
#import <react/imagemanager/ImageResponseObserver.h>
|
||||
#import <react/utils/ManagedObjectWrapper.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
@@ -20,7 +21,7 @@ RCTImageResponseObserverProxy::RCTImageResponseObserverProxy(void *delegate)
|
||||
|
||||
void RCTImageResponseObserverProxy::didReceiveImage(ImageResponse const &imageResponse) const
|
||||
{
|
||||
UIImage *image = (__bridge UIImage *)imageResponse.getImage().get();
|
||||
UIImage *image = (UIImage *)unwrapManagedObject(imageResponse.getImage());
|
||||
auto this_ = this;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[delegate_ didReceiveImage:image fromObserver:this_];
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#import "RCTImageManager.h"
|
||||
|
||||
#import <react/debug/SystraceSection.h>
|
||||
#import <react/utils/ManagedObjectWrapper.h>
|
||||
#import <react/utils/SharedFunction.h>
|
||||
|
||||
#import <React/RCTImageLoader.h>
|
||||
@@ -65,8 +66,7 @@ using namespace facebook::react;
|
||||
}
|
||||
|
||||
if (image && !error) {
|
||||
auto imageResponse = ImageResponse(std::shared_ptr<void>((__bridge_retained void *)image, CFRelease));
|
||||
observerCoordinator->nativeImageResponseComplete(std::move(imageResponse));
|
||||
observerCoordinator->nativeImageResponseComplete(ImageResponse(wrapManagedObject(image)));
|
||||
} else {
|
||||
observerCoordinator->nativeImageResponseFailed();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user