mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate to Kotlin - DebugCorePackage (#50521)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50521 This diff migrates the following file to Kotlin - DebugCorePackage as part of our ongoing effort of migrating the codebase to Kotlin Changelog: [Internal] [Changed] - Migrate to Kotlin - DebugCorePackage Reviewed By: javache Differential Revision: D72556867 fbshipit-source-id: dc37538da7089f532dc3a617a8e7dbccc6e187e3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
833ab6fe1b
commit
f87ae249c9
@@ -12,7 +12,7 @@ public class com/facebook/react/CoreModulesPackage$$ReactModuleInfoProvider : co
|
||||
public fun getReactModuleInfos ()Ljava/util/Map;
|
||||
}
|
||||
|
||||
public class com/facebook/react/DebugCorePackage : com/facebook/react/BaseReactPackage, com/facebook/react/ViewManagerOnDemandReactPackage {
|
||||
public final class com/facebook/react/DebugCorePackage : com/facebook/react/BaseReactPackage, com/facebook/react/ViewManagerOnDemandReactPackage {
|
||||
public fun <init> ()V
|
||||
public fun createViewManager (Lcom/facebook/react/bridge/ReactApplicationContext;Ljava/lang/String;)Lcom/facebook/react/uimanager/ViewManager;
|
||||
public fun getModule (Ljava/lang/String;Lcom/facebook/react/bridge/ReactApplicationContext;)Lcom/facebook/react/bridge/NativeModule;
|
||||
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.react;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
import com.facebook.react.bridge.ModuleSpec;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.module.annotations.ReactModuleList;
|
||||
import com.facebook.react.module.model.ReactModuleInfo;
|
||||
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.views.debuggingoverlay.DebuggingOverlayManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Package defining core framework modules (e.g. UIManager). It should be used for modules that
|
||||
* require special integration with other framework parts (e.g. with the list of packages to load
|
||||
* view managers from).
|
||||
*/
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
@ReactModuleList(nativeModules = {})
|
||||
/* package */
|
||||
public class DebugCorePackage extends BaseReactPackage implements ViewManagerOnDemandReactPackage {
|
||||
private @Nullable Map<String, ModuleSpec> mViewManagers;
|
||||
|
||||
public DebugCorePackage() {}
|
||||
|
||||
@Override
|
||||
public @Nullable NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
||||
return new ReactModuleInfoProvider() {
|
||||
@Override
|
||||
public Map<String, ReactModuleInfo> getReactModuleInfos() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a map of view managers that should be registered with {@link UIManager}
|
||||
*/
|
||||
private Map<String, ModuleSpec> getViewManagersMap() {
|
||||
if (mViewManagers == null) {
|
||||
Map<String, ModuleSpec> viewManagers = new HashMap<>();
|
||||
viewManagers.put(
|
||||
DebuggingOverlayManager.REACT_CLASS,
|
||||
ModuleSpec.viewManagerSpec(DebuggingOverlayManager::new));
|
||||
mViewManagers = viewManagers;
|
||||
}
|
||||
return mViewManagers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModuleSpec> getViewManagers(ReactApplicationContext reactContext) {
|
||||
return new ArrayList<>(getViewManagersMap().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getViewManagerNames(ReactApplicationContext reactContext) {
|
||||
return getViewManagersMap().keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ViewManager createViewManager(
|
||||
ReactApplicationContext reactContext, String viewManagerName) {
|
||||
ModuleSpec spec = getViewManagersMap().get(viewManagerName);
|
||||
return spec != null ? (ViewManager) spec.getProvider().get() : null;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.react
|
||||
|
||||
import com.facebook.react.bridge.ModuleSpec
|
||||
import com.facebook.react.bridge.NativeModule
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.UIManager
|
||||
import com.facebook.react.module.annotations.ReactModuleList
|
||||
import com.facebook.react.module.model.ReactModuleInfoProvider
|
||||
import com.facebook.react.uimanager.ViewManager
|
||||
import com.facebook.react.views.debuggingoverlay.DebuggingOverlayManager
|
||||
|
||||
/**
|
||||
* Package defining core framework modules (e.g. [UIManager]). It should be used for modules that
|
||||
* require special integration with other framework parts (e.g. with the list of packages to load
|
||||
* view managers from).
|
||||
*/
|
||||
@ReactModuleList(nativeModules = [])
|
||||
public class DebugCorePackage public constructor() :
|
||||
BaseReactPackage(), ViewManagerOnDemandReactPackage {
|
||||
|
||||
/** A map of view managers that should be registered with [UIManager] */
|
||||
private val viewManagersMap: Map<String, ModuleSpec> by
|
||||
lazy(LazyThreadSafetyMode.NONE) {
|
||||
mapOf(
|
||||
DebuggingOverlayManager.REACT_CLASS to
|
||||
ModuleSpec.viewManagerSpec { DebuggingOverlayManager() })
|
||||
}
|
||||
|
||||
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
|
||||
emptyMap()
|
||||
}
|
||||
|
||||
public override fun getModule(
|
||||
name: String,
|
||||
reactContext: ReactApplicationContext
|
||||
): NativeModule? = null
|
||||
|
||||
public override fun getViewManagers(reactContext: ReactApplicationContext): List<ModuleSpec> =
|
||||
viewManagersMap.values.toList()
|
||||
|
||||
override fun getViewManagerNames(reactContext: ReactApplicationContext): Collection<String> =
|
||||
viewManagersMap.keys
|
||||
|
||||
override fun createViewManager(
|
||||
reactContext: ReactApplicationContext,
|
||||
viewManagerName: String
|
||||
): ViewManager<*, *>? =
|
||||
viewManagersMap.getOrDefault(viewManagerName, null)?.provider?.get() as? ViewManager<*, *>
|
||||
}
|
||||
Reference in New Issue
Block a user