diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 9ee57ebad7b..cd8f1a4cb3e 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -29,7 +29,6 @@ #import #import #import -#import #import #import #import @@ -245,7 +244,7 @@ using namespace facebook::react; _contextContainer->registerInstance(runtimeExecutor, "runtime-executor"); - _contextContainer->registerInstance(std::make_shared((__bridge void *)[_bridge imageLoader]), "ImageManager"); + _contextContainer->registerInstance(wrapManagedObject([_bridge imageLoader]), "RCTImageLoader"); return _contextContainer; } diff --git a/ReactCommon/fabric/components/image/ImageComponentDescriptor.h b/ReactCommon/fabric/components/image/ImageComponentDescriptor.h index 3a535789ffa..d05be1215fe 100644 --- a/ReactCommon/fabric/components/image/ImageComponentDescriptor.h +++ b/ReactCommon/fabric/components/image/ImageComponentDescriptor.h @@ -25,19 +25,7 @@ class ImageComponentDescriptor final EventDispatcher::Shared eventDispatcher, ContextContainer::Shared const &contextContainer) : ConcreteComponentDescriptor(eventDispatcher), - // TODO (39486757): implement image manager on Android, currently Android does - // not have an ImageManager so this will crash -#ifndef ANDROID - imageManager_( - contextContainer - ? contextContainer->getInstance( - "ImageManager") - : nullptr) { - } -#else - imageManager_(nullptr) { - } -#endif + imageManager_(std::make_shared(contextContainer)){}; void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); diff --git a/ReactCommon/fabric/components/slider/SliderComponentDescriptor.h b/ReactCommon/fabric/components/slider/SliderComponentDescriptor.h index 03cd413621e..725d08bd412 100644 --- a/ReactCommon/fabric/components/slider/SliderComponentDescriptor.h +++ b/ReactCommon/fabric/components/slider/SliderComponentDescriptor.h @@ -24,22 +24,11 @@ class SliderComponentDescriptor final EventDispatcher::Shared eventDispatcher, ContextContainer::Shared const &contextContainer) : ConcreteComponentDescriptor(eventDispatcher), - // TODO (39486757): implement image manager on Android, currently Android does - // not have an ImageManager so this will crash -#ifndef ANDROID - imageManager_( - contextContainer - ? contextContainer->getInstance( - "ImageManager") - : nullptr), -#else - imageManager_(nullptr), -#endif + imageManager_(std::make_shared(contextContainer)), measurementsManager_( SliderMeasurementsManager::shouldMeasureSlider() ? std::make_shared(contextContainer) - : nullptr) { - } + : nullptr) {} void adopt(UnsharedShadowNode shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); diff --git a/ReactCommon/fabric/imagemanager/ImageManager.h b/ReactCommon/fabric/imagemanager/ImageManager.h index dba71a37708..90722aa892f 100644 --- a/ReactCommon/fabric/imagemanager/ImageManager.h +++ b/ReactCommon/fabric/imagemanager/ImageManager.h @@ -11,6 +11,7 @@ #include #include +#include namespace facebook { namespace react { @@ -24,7 +25,7 @@ using SharedImageManager = std::shared_ptr; */ class ImageManager { public: - ImageManager(void *platformSpecificCounterpart); + ImageManager(ContextContainer::Shared const &contextContainer); ~ImageManager(); ImageRequest requestImage(const ImageSource &imageSource) const; diff --git a/ReactCommon/fabric/imagemanager/platform/android/ImageManager.cpp b/ReactCommon/fabric/imagemanager/platform/android/ImageManager.cpp index fce052dccc6..46e82454926 100644 --- a/ReactCommon/fabric/imagemanager/platform/android/ImageManager.cpp +++ b/ReactCommon/fabric/imagemanager/platform/android/ImageManager.cpp @@ -10,7 +10,7 @@ namespace facebook { namespace react { -ImageManager::ImageManager(void *platformSpecificCounterpart) { +ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) { // Silence unused-private-field warning. (void)self_; // Not implemented. diff --git a/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm b/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm index 62255d9bdc0..d5c64f5f06b 100644 --- a/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm +++ b/ReactCommon/fabric/imagemanager/platform/ios/ImageManager.mm @@ -8,16 +8,18 @@ #include "ImageManager.h" #import +#import #import "RCTImageManager.h" namespace facebook { namespace react { -ImageManager::ImageManager(void *platformSpecificCounterpart) { - self_ = (__bridge_retained void *)[[RCTImageManager alloc] - initWithImageLoader:(__bridge RCTImageLoader *) - platformSpecificCounterpart]; +ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) +{ + RCTImageLoader *imageLoader = + (RCTImageLoader *)unwrapManagedObject(contextContainer->getInstance>("RCTImageLoader")); + self_ = (__bridge_retained void *)[[RCTImageManager alloc] initWithImageLoader:imageLoader]; } ImageManager::~ImageManager() { diff --git a/ReactCommon/fabric/uimanager/tests/UITemplateProcessorTest.cpp b/ReactCommon/fabric/uimanager/tests/UITemplateProcessorTest.cpp index 8af2d36360f..7a16b525552 100644 --- a/ReactCommon/fabric/uimanager/tests/UITemplateProcessorTest.cpp +++ b/ReactCommon/fabric/uimanager/tests/UITemplateProcessorTest.cpp @@ -14,7 +14,6 @@ using namespace facebook::react; -#include #include #include #include @@ -33,9 +32,6 @@ ComponentRegistryFactory getDefaultComponentRegistryFactory() { auto registry = std::make_shared(); registry->registerComponentDescriptor( std::make_shared(eventDispatcher)); - registry->registerComponentDescriptor( - std::make_shared( - eventDispatcher, contextContainer)); registry->registerComponentDescriptor( std::make_shared(eventDispatcher)); registry->registerComponentDescriptor(