private void showFragment(Class<? extends JRUiFragment> fragClass, int requestCode) {
    JRUiFragment f;
    try {
      f = fragClass.newInstance();
    } catch (java.lang.InstantiationException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
    Bundle args = new Bundle();
    args.putInt(JR_FRAGMENT_FLOW_MODE, getFragmentFlowMode());
    f.setArguments(args);
    f.setTargetFragment(this, requestCode);

    getActivity()
        .getSupportFragmentManager()
        .beginTransaction()
        .replace(((ViewGroup) getView().getParent()).getId(), f)
        .addToBackStack(fragClass.getSimpleName())
        .setTransition(FragmentTransaction.TRANSIT_NONE)
        .commit();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LogUtils.logd(TAG, "[onCreate]: " + getFragmentId());

    JRSession session = JRSession.getInstance();

    if (session == null || savedInstanceState != null) {
      /* This flow control path is reached when there's process death and restart */
      Log.e(TAG, "bailing out after a process kill/restart. mSession: " + session);

      // prevent fragment recreation error -- the system needs the fragment's container to exist
      // even if the Activity is finishing right away
      setContentView(R.layout.jr_fragment_host_activity);
      super.finish();
      return;
    }

    switch (getFragmentId()) {
      case JR_PROVIDER_LIST:
        mUiFragment = new JRProviderListFragment();
        break;
      case JR_LANDING:
        mUiFragment = new JRLandingFragment();
        break;
      case JR_WEBVIEW:
        mUiFragment = new JRWebViewFragment();
        break;
      case JR_PUBLISH:
        mUiFragment = new JRPublishFragment();
        break;
      case JR_OPENID_APPAUTH:
        mUiFragment = new JROpenIDAppAuthFragment();
        break;
      default:
        throw new IllegalFragmentIdException(getFragmentId());
    }

    Bundle fragArgs = new Bundle();
    fragArgs.putInt(JRUiFragment.JR_FRAGMENT_FLOW_MODE, getFlowMode());
    fragArgs.putAll(getIntent().getExtras());
    mUiFragment.setArguments(fragArgs);

    mUiFragment.onFragmentHostActivityCreate(this, session);

    if (shouldBeDialog()) {
      AndroidUtils.activitySetFinishOnTouchOutside(this, true);

      if (shouldBePhoneSizedDialog()) {
        getTheme().applyStyle(R.style.jr_dialog_phone_sized, true);
      } else {
        getTheme().applyStyle(R.style.jr_dialog_71_percent, true);
      }

      if (!mUiFragment.shouldShowTitleWhenDialog()) {
        getTheme().applyStyle(R.style.jr_disable_title_and_action_bar_style, true);
      }
    } else if (getOperationMode() == JR_FULLSCREEN_NO_TITLE) {
      getWindow().requestFeature(Window.FEATURE_NO_TITLE);
      getTheme().applyStyle(R.style.jr_disable_title_and_action_bar_style, true);
    } else if (getOperationMode() == JR_FULLSCREEN) {
      // noop
    }

    setContentView(R.layout.jr_fragment_host_activity);

    View fragmentContainer = findViewById(R.id.jr_fragment_container);
    if (fragmentContainer instanceof CustomMeasuringFrameLayout) {
      // CMFL -> dialog mode on a tablet
      if (shouldBePhoneSizedDialog()) {
        // Do the actual setting of the target size to achieve phone sized dialog.
        ((CustomMeasuringFrameLayout) fragmentContainer).setTargetSizeDip(320, 480);
        getWindow().makeActive();
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
        lp.copyFrom(getWindow().getAttributes());
        lp.width = AndroidUtils.scaleDipToPixels(320);
        // After discussing it with Lilli we think it makes sense to let the height of the window
        // grow if the title is enabled
        // int targetHeight = mUiFragment.getCustomTitle() == null ? 480 : 560;
        // lp.height = AndroidUtils.scaleDipToPixels(targetHeight);
        getWindow().setAttributes(lp);
      }
    }

    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.jr_fragment_container, mUiFragment)
        .setTransition(FragmentTransaction.TRANSIT_NONE)
        .commit();
  }