当前位置: 首页>>代码示例>>Java>>正文


Java ReactRootView类代码示例

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


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

示例1: initializePage

import com.facebook.react.ReactRootView; //导入依赖的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);
}
 
开发者ID:sonnylazuardi,项目名称:react-native-image-intent,代码行数:17,代码来源:MainActivity.java

示例2: onCreateView

import com.facebook.react.ReactRootView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    boolean needToEnableDevMenu = false;

    if (getReactNativeHost().getUseDeveloperSupport()
            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
            && !Settings.canDrawOverlays(getContext())) {
        // Get permission to show redbox in dev builds.
        needToEnableDevMenu = true;
        Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getContext().getPackageName()));
        Toast.makeText(getContext(), REDBOX_PERMISSION_MESSAGE, Toast.LENGTH_LONG).show();
        startActivityForResult(serviceIntent, REQUEST_OVERLAY_CODE);
    }

    mReactRootView = new ReactRootView(getContext());

    if (!needToEnableDevMenu) {
        mReactRootView.startReactApplication(
                getReactNativeHost().getReactInstanceManager(),
                mComponentName,
                mLaunchOptions);
    }

    return mReactRootView;
}
 
开发者ID:hudl,项目名称:react-native-android-fragment,代码行数:27,代码来源:ReactFragment.java

示例3: testResizeRootView

import com.facebook.react.ReactRootView; //导入依赖的package包/类
@Ignore("t6596940: fix intermittently failing test")
public void testResizeRootView() throws Throwable {
  final ReactRootView rootView = (ReactRootView) getRootView();
  final View childView = rootView.getChildAt(0);

  assertEquals(rootView.getWidth(), childView.getWidth());

  final int newWidth = rootView.getWidth() / 2;

  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          rootView.setLayoutParams(new FrameLayout.LayoutParams(
                  newWidth,
                  ViewGroup.LayoutParams.MATCH_PARENT));
        }
      });

  getInstrumentation().waitForIdleSync();
  waitForBridgeAndUIIdle();

  assertEquals(newWidth, childView.getWidth());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:25,代码来源:ReactRootViewTestCase.java

示例4: _testCenteredText

import com.facebook.react.ReactRootView; //导入依赖的package包/类
public void _testCenteredText(String text) {
  ReactRootView rootView = new ReactRootView(getContext());
  int rootTag = uiManager.addMeasuredRootView(rootView);

  jsModule.renderCenteredTextViewTestApplication(rootTag, text);
  waitForBridgeAndUIIdle();

  TextView textView = getViewByTestId(rootView, "text");

  // text view should be centered
  String msg = "text `" + text + "` is not centered";
  assertTrue(msg, textView.getLeft() > 0.1);
  assertTrue(msg, textView.getTop() > 0.1);
  assertEquals(
      msg,
      (int) Math.ceil((inPixelRounded(200) - textView.getWidth()) * 0.5f),
      textView.getLeft());
  assertEquals(
      msg,
      (int) Math.ceil((inPixelRounded(100) - textView.getHeight()) * 0.5f),
      textView.getTop());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:23,代码来源:CatalystUIManagerTestCase.java

示例5: onCreate

import com.facebook.react.ReactRootView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  overridePendingTransition(0, 0);

  // We wrap screenshot layout in another FrameLayout in order to handle custom dimensions of the
  // screenshot view set through {@link #setScreenshotDimensions}
  FrameLayout rootView = new FrameLayout(this);
  setContentView(rootView);

  mScreenshotingFrameLayout = new ScreenshotingFrameLayout(this);
  mScreenshotingFrameLayout.setId(ROOT_VIEW_ID);
  rootView.addView(mScreenshotingFrameLayout);

  mReactRootView = new ReactRootView(this);
  mScreenshotingFrameLayout.addView(mReactRootView);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactAppTestActivity.java

示例6: testFontFamilyBoldItalicStyleApplied

import com.facebook.react.ReactRootView; //导入依赖的package包/类
@Test
public void testFontFamilyBoldItalicStyleApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(
          ViewProps.FONT_FAMILY, "sans-serif",
          ViewProps.FONT_WEIGHT, "500",
          ViewProps.FONT_STYLE, "italic"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  CustomStyleSpan customStyleSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class);
  assertThat(customStyleSpan.getFontFamily()).isEqualTo("sans-serif");
  assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isNotZero();
  assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactTextTest.java

示例7: testTextDecorationLineUnderlineApplied

import com.facebook.react.ReactRootView; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ReactTextTest.java

示例8: testTextDecorationLineLineThroughApplied

import com.facebook.react.ReactRootView; //导入依赖的package包/类
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactTextTest.java

示例9: testTextDecorationLineUnderlineLineThroughApplied

import com.facebook.react.ReactRootView; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactTextTest.java

示例10: onCreate

import com.facebook.react.ReactRootView; //导入依赖的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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:MainActivity.java

示例11: onCreate

import com.facebook.react.ReactRootView; //导入依赖的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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:20,代码来源:patchedMainActivity.java

示例12: onCreate

import com.facebook.react.ReactRootView; //导入依赖的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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:21,代码来源:MainActivity.java

示例13: onCreate

import com.facebook.react.ReactRootView; //导入依赖的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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:MainActivity.java

示例14: onCreate

import com.facebook.react.ReactRootView; //导入依赖的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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:MainActivity.java

示例15: getSharedElementOptionsBundle

import com.facebook.react.ReactRootView; //导入依赖的package包/类
static Bundle getSharedElementOptionsBundle(
        Activity activity, Intent intent, @Nullable ReadableMap options) {
  ViewGroup transitionGroup = null;
  if (activity instanceof ReactInterface && options != null &&
          options.hasKey(SHARED_ELEMENT_TRANSITION_GROUP_OPTION)) {
    ReactRootView reactRootView = ((ReactInterface) activity).getReactRootView();
    transitionGroup = ViewUtils.findViewGroupWithTag(
            reactRootView,
            R.id.react_shared_element_group_id,
            options.getString(SHARED_ELEMENT_TRANSITION_GROUP_OPTION));
  }

  if (transitionGroup == null) {
    // Even though there is no transition group, we want the activity options to include a scene
    // transition so that we can postpone the enter transition.
    //noinspection unchecked
    return ActivityOptionsCompat.makeSceneTransitionAnimation(activity).toBundle();
  } else {
    ReactNativeUtils.setIsSharedElementTransition(intent);
    return AutoSharedElementCallback.getActivityOptionsBundle(activity, transitionGroup);
  }
}
 
开发者ID:airbnb,项目名称:native-navigation,代码行数:23,代码来源:ReactNativeIntents.java


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