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); }
@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; }
@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()); }
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()); }
@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); }
@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(); }
@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); }
@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(); }
@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(); }
@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); }
@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); }
@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); }
@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); }
@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); }
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); } }
@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); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getUseDeveloperSupport() && Build.VERSION.SDK_INT >= 23) { // Get permission to show redbox in dev builds. if (!Settings.canDrawOverlays(this)) { Intent serviceIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); startActivity(serviceIntent); FLog.w(ReactConstants.TAG, REDBOX_PERMISSION_MESSAGE); Toast.makeText(this, REDBOX_PERMISSION_MESSAGE, Toast.LENGTH_LONG).show(); } } mReactInstanceManager = ReactInstanceSingleton.getReactInstanceManager(getApplication()); ReactRootView mReactRootView = createRootView(); mReactRootView.startReactApplication(mReactInstanceManager, getMainComponentName(), getLaunchOptions()); setContentView(mReactRootView); }
@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); }