|
1 | 1 | package org.linusu; |
2 | 2 |
|
3 | | -import java.util.Arrays; |
4 | | -import java.util.Collections; |
5 | | -import java.util.List; |
| 3 | +import java.util.HashMap; |
| 4 | +import java.util.Map; |
6 | 5 |
|
7 | | -import com.facebook.react.ReactPackage; |
| 6 | +import com.facebook.react.BaseReactPackage; |
8 | 7 | import com.facebook.react.bridge.NativeModule; |
9 | 8 | import com.facebook.react.bridge.ReactApplicationContext; |
10 | | -import com.facebook.react.uimanager.ViewManager; |
11 | | -import com.facebook.react.bridge.JavaScriptModule; |
| 9 | +import com.facebook.react.module.model.ReactModuleInfo; |
| 10 | +import com.facebook.react.module.model.ReactModuleInfoProvider; |
12 | 11 |
|
13 | | -public class RNGetRandomValuesPackage implements ReactPackage { |
| 12 | +public class RNGetRandomValuesPackage extends BaseReactPackage { |
14 | 13 | @Override |
15 | | - public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { |
16 | | - return Arrays.<NativeModule>asList(new RNGetRandomValuesModule(reactContext)); |
17 | | - } |
18 | | - |
19 | | - // Deprecated from RN 0.47 |
20 | | - public List<Class<? extends JavaScriptModule>> createJSModules() { |
21 | | - return Collections.emptyList(); |
| 14 | + public NativeModule getModule(String name, ReactApplicationContext reactContext) { |
| 15 | + if (name.equals(RNGetRandomValuesModule.NAME)) { |
| 16 | + return new RNGetRandomValuesModule(reactContext); |
| 17 | + } else { |
| 18 | + return null; |
| 19 | + } |
22 | 20 | } |
23 | 21 |
|
24 | 22 | @Override |
25 | | - public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { |
26 | | - return Collections.emptyList(); |
| 23 | + public ReactModuleInfoProvider getReactModuleInfoProvider() { |
| 24 | + return new ReactModuleInfoProvider() { |
| 25 | + @Override |
| 26 | + public Map<String, ReactModuleInfo> getReactModuleInfos() { |
| 27 | + Map<String, ReactModuleInfo> map = new HashMap<>(); |
| 28 | + map.put(RNGetRandomValuesModule.NAME, new ReactModuleInfo( |
| 29 | + RNGetRandomValuesModule.NAME, // name |
| 30 | + RNGetRandomValuesModule.NAME, // className |
| 31 | + false, // canOverrideExistingModule |
| 32 | + false, // needsEagerInit |
| 33 | + false, // isCXXModule |
| 34 | + true // isTurboModule |
| 35 | + )); |
| 36 | + return map; |
| 37 | + } |
| 38 | + }; |
27 | 39 | } |
28 | 40 | } |
0 commit comments