-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make UIConstantsProviderManager a static method
Differential Revision: D55241233
- Loading branch information
1 parent
b1066ba
commit fefb6c0
Showing
9 changed files
with
129 additions
and
216 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
64 changes: 64 additions & 0 deletions
64
...ges/react-native/ReactAndroid/src/main/jni/react/uimanager/UIConstantsProviderBinding.cpp
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "UIConstantsProviderBinding.h" | ||
|
||
#include <react/runtime/nativeviewconfig/LegacyUIManagerConstantsProviderBinding.h> | ||
|
||
namespace facebook::react { | ||
|
||
using namespace facebook::jni; | ||
|
||
void UIConstantsProviderBinding::registerNatives() { | ||
javaClassStatic()->registerNatives({ | ||
makeNativeMethod("install", UIConstantsProviderBinding::install), | ||
}); | ||
} | ||
|
||
void UIConstantsProviderBinding::install( | ||
jni::alias_ref<jclass> /* unused */, | ||
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutor, | ||
jni::alias_ref<DefaultEventTypesProvider::javaobject> | ||
defaultExportableEventTypesProvider, | ||
jni::alias_ref<ConstantsForViewManagerProvider::javaobject> | ||
constantsForViewManagerProvider, | ||
jni::alias_ref<ConstantsProvider::javaobject> constantsProvider) { | ||
auto executor = runtimeExecutor->cthis()->get(); | ||
executor([defaultExportableEventTypesProvider = | ||
make_global(defaultExportableEventTypesProvider), | ||
constantsForViewManagerProvider = | ||
make_global(constantsForViewManagerProvider), | ||
constantsProvider = | ||
make_global(constantsProvider)](jsi::Runtime& runtime) { | ||
LegacyUIManagerConstantsProviderBinding::install( | ||
runtime, | ||
"getDefaultEventTypes", | ||
[provider = std::move(defaultExportableEventTypesProvider)]( | ||
jsi::Runtime& runtime) { | ||
return jsi::valueFromDynamic( | ||
runtime, provider->getDefaultEventTypes()); | ||
}); | ||
|
||
LegacyUIManagerConstantsProviderBinding::install( | ||
runtime, | ||
"getConstantsForViewManager", | ||
[provider = std::move(constantsForViewManagerProvider)]( | ||
jsi::Runtime& runtime, const std::string& viewManagerName) { | ||
return jsi::valueFromDynamic( | ||
runtime, provider->getConstantsForViewManager(viewManagerName)); | ||
}); | ||
|
||
LegacyUIManagerConstantsProviderBinding::install( | ||
runtime, | ||
"getConstants", | ||
[provider = std::move(constantsProvider)](jsi::Runtime& runtime) { | ||
return jsi::valueFromDynamic(runtime, provider->getConstants()); | ||
}); | ||
}); | ||
} | ||
|
||
} // namespace facebook::react |
This file contains 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
Oops, something went wrong.