下面列出了怎么用com.facebook.react.bridge.ReactApplicationContext的API类实例代码及写法,或者点击链接到github查看源代码。
@Test
@Config(sdk = Build.VERSION_CODES.P)
public void testGetSecurityLevel_NoBiometry_api28() throws Exception {
// GIVE:
final ReactApplicationContext context = getRNContext();
final KeychainModule module = new KeychainModule(context);
final Promise mockPromise = mock(Promise.class);
// WHEN:
final JavaOnlyMap options = new JavaOnlyMap();
options.putString(Maps.ACCESS_CONTROL, AccessControl.DEVICE_PASSCODE);
module.getSecurityLevel(options, mockPromise);
// THEN:
verify(mockPromise).resolve(SecurityLevel.SECURE_HARDWARE.name());
}
@Deprecated
public UIManagerModule(
ReactApplicationContext reactContext,
ViewManagerResolver viewManagerResolver,
UIImplementationProvider uiImplementationProvider,
int minTimeLeftInFrameForNonBatchedOperationMs) {
super(reactContext);
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
mEventDispatcher = new EventDispatcher(reactContext);
mModuleConstants = createConstants(viewManagerResolver);
mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants();
mUIImplementation =
uiImplementationProvider.createUIImplementation(
reactContext,
viewManagerResolver,
mEventDispatcher,
minTimeLeftInFrameForNonBatchedOperationMs);
reactContext.addLifecycleEventListener(this);
}
private static Context getNonBuggyContext(ThemedReactContext reactContext,
ReactApplicationContext appContext) {
Context superContext = reactContext;
if (!contextHasBug(appContext.getCurrentActivity())) {
superContext = appContext.getCurrentActivity();
} else if (contextHasBug(superContext)) {
// we have the bug! let's try to find a better context to use
if (!contextHasBug(reactContext.getCurrentActivity())) {
superContext = reactContext.getCurrentActivity();
} else if (!contextHasBug(reactContext.getApplicationContext())) {
superContext = reactContext.getApplicationContext();
} else {
// ¯\_(ツ)_/¯
}
}
return superContext;
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new ReactNativeOBD2Module(reactContext));
return modules;
}
public ProximityManager(ReactApplicationContext context, EventManager em) {
eventManager = em;
powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
initProximityWakeLock();
}
public NearbyConnectionModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
onResume();
setLifecycleListeners();
}
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new AccountManagerModule(reactContext));
return modules;
}
public FirestackStorage(ReactApplicationContext reactContext) {
super(reactContext);
Log.d(TAG, "Attaching FirestackStorage");
this.context = reactContext;
mReactContext = reactContext;
Log.d(TAG, "New instance");
}
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new DynamicSplashModule(reactContext));
return modules;
}
public RNBluetoothManagerModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
reactContext.addLifecycleEventListener(this);
btAdapter = BluetoothAdapter.getDefaultAdapter();
registerBroadcastReceiver();
}
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new ProxiedFetchModule(reactContext));
return modules;
}
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new SplashScreenModule(reactContext));
return modules;
}
public static void sendEvent(ReactApplicationContext reactContext,
String eventName,
WritableMap params) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
}
@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new LANScanModule(reactContext));
return modules;
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new FlurryModule(reactContext));
return modules;
}
public RCTCameraModule(ReactApplicationContext reactContext) {
super(reactContext);
_reactContext = reactContext;
_sensorOrientationChecker = new RCTSensorOrientationChecker(_reactContext);
_reactContext.addLifecycleEventListener(this);
sound.load(MediaActionSound.SHUTTER_CLICK);
}
public SmsListenerModule(ReactApplicationContext context) {
super(context);
mReceiver = new SmsReceiver(context);
getReactApplicationContext().addLifecycleEventListener(this);
registerReceiverIfNecessary(mReceiver);
}
@Override
public void initialize() {
ReactApplicationContext reactCtx = getReactApplicationContext();
UIManagerModule uiManager = reactCtx.getNativeModule(UIManagerModule.class);
reactCtx.addLifecycleEventListener(this);
uiManager.addUIManagerListener(this);
}
public RNShineButtonModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new RNMessageComposeModule(reactContext));
}
@NonNull
@Override
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.emptyList();
}
public InstagramStoriesShare(ReactApplicationContext reactContext) {
super(reactContext);
this.setIntent(new Intent("com.instagram.share.ADD_TO_STORY"));
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new MidtransModule(reactContext));
}
@SuppressWarnings("rawtypes") @Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.<ViewManager>singletonList(new LottieAnimationViewManager());
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new ShareExModule(reactContext));
}
public CrosswalkWebViewGroupManager (ReactApplicationContext _reactContext) {
reactContext = _reactContext;
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@Override
@NonNull
public List<NativeModule> createNativeModules(@NonNull final ReactApplicationContext reactContext) {
return Collections.singletonList(KeychainModule.withWarming(reactContext));
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
public SQLitePlugin(ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext.getApplicationContext();
this.threadPool = Executors.newCachedThreadPool();
}