Files
react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java
T
David Vacca aa5edca0e2 Migrate Nullable and NonNull annotations to AndroidX
Summary:
This diff migrates the usages Nullable and NonNull annotations to AndroidX instead of javax.

The purpose of this change is to bring consistency in the annotations used by the core of RN

Reviewed By: makovkastar

Differential Revision: D16054504

fbshipit-source-id: 21d888854da088d2a14615a90d4dc058e5286b91
2019-07-11 16:23:29 -07:00

56 lines
2.0 KiB
Java

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>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.uimanager;
import android.app.Activity;
import android.content.Context;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
/**
* Wraps {@link ReactContext} with the base {@link Context} passed into the constructor. It provides
* also a way to start activities using the viewContext to which RN native views belong. It
* delegates lifecycle listener registration to the original instance of {@link ReactContext} which
* is supposed to receive the lifecycle events. At the same time we disallow receiving lifecycle
* events for this wrapper instances. TODO: T7538544 Rename ThemedReactContext to be in alignment
* with name of ReactApplicationContext
*/
public class ThemedReactContext extends ReactContext {
private final ReactApplicationContext mReactApplicationContext;
public ThemedReactContext(ReactApplicationContext reactApplicationContext, Context base) {
super(base);
if (reactApplicationContext.hasCatalystInstance()) {
initializeWithInstance(reactApplicationContext.getCatalystInstance());
}
mReactApplicationContext = reactApplicationContext;
}
@Override
public void addLifecycleEventListener(LifecycleEventListener listener) {
mReactApplicationContext.addLifecycleEventListener(listener);
}
@Override
public void removeLifecycleEventListener(LifecycleEventListener listener) {
mReactApplicationContext.removeLifecycleEventListener(listener);
}
@Override
public boolean hasCurrentActivity() {
return mReactApplicationContext.hasCurrentActivity();
}
@Override
public @Nullable Activity getCurrentActivity() {
return mReactApplicationContext.getCurrentActivity();
}
}