• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CatalystInstance类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.facebook.react.bridge.CatalystInstance的典型用法代码示例。如果您正苦于以下问题:Java CatalystInstance类的具体用法?Java CatalystInstance怎么用?Java CatalystInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CatalystInstance类属于com.facebook.react.bridge包,在下文中一共展示了CatalystInstance类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: callJavaScript

import com.facebook.react.bridge.CatalystInstance; //导入依赖的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);
        }
    }
}
 
开发者ID:petterh,项目名称:react-native-android-activity,代码行数:18,代码来源:ActivityStarterModule.java


示例2: attachMeasuredRootViewToInstance

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
private void attachMeasuredRootViewToInstance(
    ReactRootView rootView,
    CatalystInstance catalystInstance) {
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachMeasuredRootViewToInstance");
  UiThreadUtil.assertOnUiThread();

  // Reset view content as it's going to be populated by the application content from JS
  rootView.removeAllViews();
  rootView.setId(View.NO_ID);

  UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
  int rootTag = uiManagerModule.addMeasuredRootView(rootView);
  rootView.setRootViewTag(rootTag);
  @Nullable Bundle launchOptions = rootView.getLaunchOptions();
  WritableMap initialProps = Arguments.makeNativeMap(launchOptions);
  String jsAppModuleName = rootView.getJSModuleName();

  WritableNativeMap appParams = new WritableNativeMap();
  appParams.putDouble("rootTag", rootTag);
  appParams.putMap("initialProps", initialProps);
  catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
  rootView.onAttachedToReactInstance();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:25,代码来源:ReactInstanceManager.java


示例3: setupReactContext

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
private void setupReactContext(ReactApplicationContext reactContext) {
  UiThreadUtil.assertOnUiThread();
  Assertions.assertCondition(mCurrentReactContext == null);
  mCurrentReactContext = Assertions.assertNotNull(reactContext);
  CatalystInstance catalystInstance =
      Assertions.assertNotNull(reactContext.getCatalystInstance());

  catalystInstance.initialize();
  mDevSupportManager.onNewReactContextCreated(reactContext);
  mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
  moveReactContextToCurrentLifecycleState();

  for (ReactRootView rootView : mAttachedRootViews) {
    attachMeasuredRootViewToInstance(rootView, catalystInstance);
  }

  ReactInstanceEventListener[] listeners =
    new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
  listeners = mReactInstanceEventListeners.toArray(listeners);

  for (ReactInstanceEventListener listener : listeners) {
    listener.onReactContextInitialized(reactContext);
  }
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:25,代码来源:ReactInstanceManagerImpl.java


示例4: attachMeasuredRootViewToInstance

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
private void attachMeasuredRootViewToInstance(
    ReactRootView rootView,
    CatalystInstance catalystInstance) {
  UiThreadUtil.assertOnUiThread();

  // Reset view content as it's going to be populated by the application content from JS
  rootView.removeAllViews();
  rootView.setId(View.NO_ID);

  UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
  int rootTag = uiManagerModule.addMeasuredRootView(rootView);
  @Nullable Bundle launchOptions = rootView.getLaunchOptions();
  WritableMap initialProps = launchOptions != null
      ? Arguments.fromBundle(launchOptions)
      : Arguments.createMap();
  String jsAppModuleName = rootView.getJSModuleName();

  WritableNativeMap appParams = new WritableNativeMap();
  appParams.putDouble("rootTag", rootTag);
  appParams.putMap("initialProps", initialProps);
  catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:23,代码来源:ReactInstanceManagerImpl.java


示例5: build

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
@Override
public CatalystInstance build() {
  return new CatalystInstanceImpl.Builder()
    .setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
    .setJSExecutor(new JSCJavaScriptExecutor(new WritableNativeMap()))
    .setRegistry(mNativeModuleRegistryBuilder.build())
    .setJSModulesConfig(mJSModulesConfigBuilder.build())
    .setJSBundleLoader(JSBundleLoader.createFileLoader(
                         mContext,
                         "assets://AndroidTestBundle.js"))
    .setNativeModuleCallExceptionHandler(
      new NativeModuleCallExceptionHandler() {
          @Override
          public void handleException(Exception e) {
            throw new RuntimeException(e);
          }
      })
    .build();
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:20,代码来源:ReactTestHelper.java


示例6: attachMeasuredRootViewToInstance

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
private void attachMeasuredRootViewToInstance(
    ReactRootView rootView,
    CatalystInstance catalystInstance) {
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachMeasuredRootViewToInstance");
  UiThreadUtil.assertOnUiThread();

  // Reset view content as it's going to be populated by the application content from JS
  rootView.removeAllViews();
  rootView.setId(View.NO_ID);

  UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
  int rootTag = uiManagerModule.addMeasuredRootView(rootView);
  rootView.setRootViewTag(rootTag);
  @Nullable Bundle launchOptions = rootView.getLaunchOptions();
  WritableMap initialProps = Arguments.makeNativeMap(launchOptions);
  String jsAppModuleName = rootView.getJSModuleName();

  WritableNativeMap appParams = new WritableNativeMap();
  appParams.putDouble("rootTag", rootTag);
  appParams.putMap("initialProps", initialProps);
  catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
开发者ID:Right-Men,项目名称:Ironman,代码行数:24,代码来源:XReactInstanceManagerImpl.java


示例7: onCreate

import com.facebook.react.bridge.CatalystInstance; //导入依赖的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);
}
 
开发者ID:alangpierce,项目名称:react-native-android-audio-demo,代码行数:17,代码来源:AudioService.java


示例8: cleanDataFromModules

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
public static void cleanDataFromModules(CatalystInstance catalystInstance) {
  for (NativeModule nativeModule : catalystInstance.getNativeModules()) {
    if (nativeModule instanceof Cleanable) {
      FLog.d(ReactConstants.TAG, "Cleaning data from " + nativeModule.getName());
      ((Cleanable) nativeModule).clearSensitiveData();
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:ModuleDataCleaner.java


示例9: setupReactContext

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
private void setupReactContext(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
  UiThreadUtil.assertOnUiThread();
  Assertions.assertCondition(mCurrentReactContext == null);
  mCurrentReactContext = Assertions.assertNotNull(reactContext);
  CatalystInstance catalystInstance =
      Assertions.assertNotNull(reactContext.getCatalystInstance());

  catalystInstance.initialize();
  mDevSupportManager.onNewReactContextCreated(reactContext);
  mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
  moveReactContextToCurrentLifecycleState();

  for (ReactRootView rootView : mAttachedRootViews) {
    attachMeasuredRootViewToInstance(rootView, catalystInstance);
  }

  ReactInstanceEventListener[] listeners =
    new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
  listeners = mReactInstanceEventListeners.toArray(listeners);

  for (ReactInstanceEventListener listener : listeners) {
    listener.onReactContextInitialized(reactContext);
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_END);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:30,代码来源:ReactInstanceManager.java


示例10: detachViewFromInstance

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
private void detachViewFromInstance(
    ReactRootView rootView,
    CatalystInstance catalystInstance) {
  UiThreadUtil.assertOnUiThread();
  catalystInstance.getJSModule(AppRegistry.class)
      .unmountApplicationComponentAtRootTag(rootView.getId());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:8,代码来源:ReactInstanceManager.java


示例11: setup

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
@Before
public void setup() {
  ReactApplicationContext mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  CatalystInstance mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactSliderManager();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:ReactSliderPropertyTest.java


示例12: catalystInstanceBuilder

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
public static ReactTestFactory.ReactInstanceEasyBuilder catalystInstanceBuilder(
    final ReactIntegrationTestCase testCase) {
  final ReactTestFactory.ReactInstanceEasyBuilder builder =
    getReactTestFactory().getCatalystInstanceBuilder();
  ReactTestFactory.ReactInstanceEasyBuilder postBuilder =
    new ReactTestFactory.ReactInstanceEasyBuilder() {
      @Override
      public ReactTestFactory.ReactInstanceEasyBuilder setContext(Context context) {
        builder.setContext(context);
        return this;
      }

      @Override
      public ReactTestFactory.ReactInstanceEasyBuilder addNativeModule(NativeModule module) {
        builder.addNativeModule(module);
        return this;
      }

      @Override
      public ReactTestFactory.ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass) {
        builder.addJSModule(moduleInterfaceClass);
        return this;
      }

      @Override
      public CatalystInstance build() {
        CatalystInstance instance = builder.build();
        testCase.initializeWithInstance(instance);
        instance.runJSBundle();
        testCase.waitForBridgeAndUIIdle();
        return instance;
      }
    };

  postBuilder.setContext(testCase.getContext());
  return postBuilder;
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:38,代码来源:ReactTestHelper.java


示例13: prepareModules

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
@Before
public void prepareModules() {
  PowerMockito.mockStatic(Arguments.class);
  when(Arguments.createArray()).thenAnswer(
      new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
          return new JavaOnlyArray();
        }
      });

  PowerMockito.mockStatic(SystemClock.class);
  when(SystemClock.currentTimeMillis()).thenReturn(mCurrentTimeNs / 1000000);
  when(SystemClock.nanoTime()).thenReturn(mCurrentTimeNs);

  mChoreographerMock = mock(ReactChoreographer.class);
  PowerMockito.mockStatic(ReactChoreographer.class);
  when(ReactChoreographer.getInstance()).thenReturn(mChoreographerMock);

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  ReactApplicationContext reactContext = mock(ReactApplicationContext.class);
  when(reactContext.getCatalystInstance()).thenReturn(reactInstance);

  mCurrentTimeNs = 0;
  mPostFrameCallbackHandler = new PostFrameCallbackHandler();

  doAnswer(mPostFrameCallbackHandler)
      .when(mChoreographerMock)
      .postFrameCallback(
          eq(ReactChoreographer.CallbackType.TIMERS_EVENTS),
          any(Choreographer.FrameCallback.class));

  mTiming = new Timing(reactContext);
  mJSTimersMock = mock(JSTimersExecution.class);
  mExecutorTokenMock = mock(ExecutorToken.class);
  when(reactContext.getJSModule(mExecutorTokenMock, JSTimersExecution.class)).thenReturn(mJSTimersMock);
  mTiming.initialize();
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:39,代码来源:TimingModuleTest.java


示例14: setupReactContext

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
private void setupReactContext(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
  UiThreadUtil.assertOnUiThread();
  Assertions.assertCondition(mCurrentReactContext == null);
  mCurrentReactContext = Assertions.assertNotNull(reactContext);
  CatalystInstance catalystInstance =
      Assertions.assertNotNull(reactContext.getCatalystInstance());

  catalystInstance.initialize();
  mDevSupportManager.onNewReactContextCreated(reactContext);
  mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
  moveReactContextToCurrentLifecycleState();

  for (ReactRootView rootView : mAttachedRootViews) {
    attachMeasuredRootViewToInstance(rootView, catalystInstance);
  }

  ReactInstanceEventListener[] listeners =
    new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
  listeners = mReactInstanceEventListeners.toArray(listeners);

  for (ReactInstanceEventListener listener : listeners) {
    listener.onReactContextInitialized(reactContext);
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_END);
}
 
开发者ID:Right-Men,项目名称:Ironman,代码行数:29,代码来源:XReactInstanceManagerImpl.java


示例15: catalystInstanceBuilder

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
public static ReactTestFactory.ReactInstanceEasyBuilder catalystInstanceBuilder(
    final ReactIntegrationTestCase testCase) {
  final ReactTestFactory.ReactInstanceEasyBuilder builder =
    getReactTestFactory().getCatalystInstanceBuilder();
  ReactTestFactory.ReactInstanceEasyBuilder postBuilder =
    new ReactTestFactory.ReactInstanceEasyBuilder() {
      @Override
      public ReactTestFactory.ReactInstanceEasyBuilder setContext(Context context) {
        builder.setContext(context);
        return this;
      }

      @Override
      public ReactTestFactory.ReactInstanceEasyBuilder addNativeModule(NativeModule module) {
        builder.addNativeModule(module);
        return this;
      }

      @Override
      public ReactTestFactory.ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass) {
        builder.addJSModule(moduleInterfaceClass);
        return this;
      }

      @Override
      public CatalystInstance build() {
        final CatalystInstance instance = builder.build();
        testCase.initializeWithInstance(instance);
        instance.runJSBundle();
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
          @Override
          public void run() {
            instance.initialize();
          }
        });
        testCase.waitForBridgeAndUIIdle();
        return instance;
      }
    };

  postBuilder.setContext(testCase.getContext());
  return postBuilder;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:44,代码来源:ReactTestHelper.java


示例16: initializeWithInstance

import com.facebook.react.bridge.CatalystInstance; //导入依赖的package包/类
public void initializeWithInstance(CatalystInstance instance) {
  mInstance = instance;
  mBridgeIdleSignaler = new ReactBridgeIdleSignaler();
  mInstance.addBridgeIdleDebugListener(mBridgeIdleSignaler);
  getContext().initializeWithInstance(mInstance);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:7,代码来源:ReactIntegrationTestCase.java



注:本文中的com.facebook.react.bridge.CatalystInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AttachOperationFailedException类代码示例发布时间:2022-05-22
下一篇:
Java Status类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap