本文整理匯總了Java中com.facebook.react.ReactInstanceManager類的典型用法代碼示例。如果您正苦於以下問題:Java ReactInstanceManager類的具體用法?Java ReactInstanceManager怎麽用?Java ReactInstanceManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ReactInstanceManager類屬於com.facebook.react包,在下文中一共展示了ReactInstanceManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializePage
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
private void initializePage() {
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new ImageIntentPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "Clarifai", null);
setContentView(com.sonnylab.imageintent.R.layout.activity_main);
((RelativeLayout) findViewById(com.sonnylab.imageintent.R.id.view_container)).addView(mReactRootView);
}
示例2: callJavaScript
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@ReactMethod
void callJavaScript() {
Activity activity = getCurrentActivity();
if (activity != null) {
MainApplication application = (MainApplication) activity.getApplication();
ReactNativeHost reactNativeHost = application.getReactNativeHost();
ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
CatalystInstance catalystInstance = reactContext.getCatalystInstance();
WritableNativeArray params = new WritableNativeArray();
params.pushString("Hello, JavaScript!");
catalystInstance.callFunction("JavaScriptVisibleToJava", "alert", params);
}
}
}
示例3: createReactInstanceManager
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected ReactInstanceManager createReactInstanceManager() {
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
.setApplication(getApplication())
.setJSMainModuleName(getJSMainModuleName())
.setUseDeveloperSupport(getUseDeveloperSupport())
.setRedBoxHandler(getRedBoxHandler())
.setUIImplementationProvider(getUIImplementationProvider())
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
.setNativeModuleCallExceptionHandler(
new ReadingNativeModuleCallExceptionHandler());
for (ReactPackage reactPackage : getPackages()) {
builder.addPackage(reactPackage);
}
String jsBundleFile = getJSBundleFile();
if (jsBundleFile != null) {
builder.setJSBundleFile(jsBundleFile);
} else {
builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
}
return builder.build();
}
示例4: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "Basic", null);
setContentView(mReactRootView);
}
示例5: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new VectorIconsPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "Basic", null);
setContentView(mReactRootView);
}
示例6: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
/* react-native icons */
.addPackage(new ReactNativeIcons())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "allyoop", null);
setContentView(mReactRootView);
}
示例7: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "nearby", null);
setContentView(mReactRootView);
}
示例8: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "address_book", null);
setContentView(mReactRootView);
}
示例9: onPostExecute
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onPostExecute(Object mURL) {
super.onPostExecute(mURL);
String mergedFilePath = (String) mURL;
if(RNUtils.checkFileMergedSucc(mergedFilePath)){
RNLog.d(" bundle file check succ : " + mergedFilePath);
}else {
RNLog.e(" bundle file check failed : " + mergedFilePath);
}
ReactInstanceManager instanceManager = RNCore.getInstance().renderReactInstanceManager(mergedFilePath,rModuleName);
rCallback.onCreatedInstanceManager(instanceManager);
ReactRootView reactRootView = new ReactRootView(rApplication);
reactRootView.startReactApplication(instanceManager,rModuleName);
rCallback.onRenderFinish(reactRootView);
}
示例10: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
ReactInstanceManager.Builder mB = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED);
mReactInstanceManager = mB.build();
mReactRootView.startReactApplication(mReactInstanceManager, "RNNote", null);
setContentView(mReactRootView);
}
示例11: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.addPackage(new NativeActivityPackage())
//.setUseOldBridge(true) // uncomment this line if your app crashes
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);
setContentView(mReactRootView);
}
示例12: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
// Show the js-controlled splash screen
SplashScreen.show(this);
// After react is initialized; set our background color (override splash screen theme)
getReactNativeHost().getReactInstanceManager().addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext context) {
// Hide the native splash screen
getWindow().getDecorView().setBackgroundColor(Color.WHITE);
}
});
super.onCreate(savedInstanceState);
}
示例13: resolveInstanceManager
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
ReactInstanceManager instanceManager = getReactInstanceManager();
if (instanceManager != null) {
return instanceManager;
}
final Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
return null;
}
ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication();
instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager();
return instanceManager;
}
示例14: onCreate
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
@Override
public void onCreate() {
ReactInstanceManager reactInstanceManager =
ReactInstanceSingleton.getReactInstanceManager(getApplication());
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
CatalystInstance catalystInstance = reactContext.getCatalystInstance();
serviceTopLevel = catalystInstance.getJSModule(ServiceTopLevel.class);
mRemoteViewsModule = catalystInstance.getJSModule(RemoteViewsModule.class);
} else {
Log.e(TAG, "Couldn't grab JS service code");
}
serviceTopLevel.initService(0);
}
示例15: getReactInstanceManager
import com.facebook.react.ReactInstanceManager; //導入依賴的package包/類
public static synchronized ReactInstanceManager getReactInstanceManager(
Application application) {
if (sSingletonManager == null) {
ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
.setApplication(application)
.setJSMainModuleName("index.android")
.setUseDeveloperSupport(BuildConfig.DEBUG)
// TODO figure out the right thing to put here.
.setInitialLifecycleState(LifecycleState.BEFORE_RESUME);
for (ReactPackage reactPackage : getPackages()) {
builder.addPackage(reactPackage);
}
builder.setBundleAssetName("index.android.bundle");
sSingletonManager = builder.build();
}
return sSingletonManager;
}