public boolean presentFragment(
      final BaseFragment fragment,
      final boolean removeLast,
      boolean forceWithoutAnimation,
      boolean check) {
    if (checkTransitionAnimation()
        || delegate != null
            && check
            && !delegate.needPresentFragment(fragment, removeLast, forceWithoutAnimation, this)
        || !fragment.onFragmentCreate()) {
      return false;
    }
    if (parentActivity.getCurrentFocus() != null) {
      AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
      NotificationCenter.getInstance().postNotificationName(NotificationCenter.hideEmojiKeyboard);
    }
    boolean needAnimation =
        Build.VERSION.SDK_INT > 10
            && !forceWithoutAnimation
            && parentActivity
                .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE)
                .getBoolean("view_animations", true);

    final BaseFragment currentFragment =
        !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;

    fragment.setParentLayout(this);
    View fragmentView = fragment.createView(parentActivity.getLayoutInflater());
    if (fragment.needAddActionBar() && fragment.actionBar != null) {
      if (removeActionBarExtraHeight) {
        fragment.actionBar.setOccupyStatusBar(false);
      }
      ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
      if (parent != null) {
        parent.removeView(fragment.actionBar);
      }
      containerViewBack.addView(fragment.actionBar);
      fragment.actionBar.setTitleOverlayText(titleOverlayText);
    }

    containerViewBack.addView(fragmentView);
    ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
    layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
    layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
    fragmentView.setLayoutParams(layoutParams);
    fragmentsStack.add(fragment);
    fragment.onResume();
    currentActionBar = fragment.actionBar;
    if (fragmentView.getBackground() == null) {
      fragmentView.setBackgroundColor(0xffffffff);
    }

    LinearLayoutContainer temp = containerView;
    containerView = containerViewBack;
    containerViewBack = temp;
    containerView.setVisibility(View.VISIBLE);
    setInnerTranslationX(0);

    bringChildToFront(containerView);

    if (!needAnimation) {
      presentFragmentInternalRemoveOld(removeLast, currentFragment);
      if (backgroundView != null) {
        backgroundView.setVisibility(VISIBLE);
      }
    }

    if (needAnimation) {
      if (useAlphaAnimations && fragmentsStack.size() == 1) {
        presentFragmentInternalRemoveOld(removeLast, currentFragment);

        ArrayList<Object> animators = new ArrayList<>();
        animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 0.0f, 1.0f));
        if (backgroundView != null) {
          backgroundView.setVisibility(VISIBLE);
          animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 0.0f, 1.0f));
        }

        currentAnimation = new AnimatorSetProxy();
        currentAnimation.playTogether(animators);
        currentAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        currentAnimation.setDuration(200);
        currentAnimation.addListener(
            new AnimatorListenerAdapterProxy() {
              @Override
              public void onAnimationEnd(Object animation) {
                onAnimationEndCheck(false);
              }

              @Override
              public void onAnimationCancel(Object animation) {
                onAnimationEndCheck(false);
              }
            });
        currentAnimation.start();
      } else {
        transitionAnimationStartTime = System.currentTimeMillis();
        transitionAnimationInProgress = true;
        onOpenAnimationEndRunnable =
            new Runnable() {
              @Override
              public void run() {
                presentFragmentInternalRemoveOld(removeLast, currentFragment);
                fragment.onOpenAnimationEnd();
                ViewProxy.setTranslationX(containerView, 0);
              }
            };
        ViewProxy.setAlpha(containerView, 0.0f);
        ViewProxy.setTranslationX(containerView, 48.0f);
        currentAnimation = new AnimatorSetProxy();
        currentAnimation.playTogether(
            ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f),
            ObjectAnimatorProxy.ofFloat(containerView, "translationX", AndroidUtilities.dp(48), 0));
        currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
        currentAnimation.setDuration(200);
        currentAnimation.addListener(
            new AnimatorListenerAdapterProxy() {
              @Override
              public void onAnimationStart(Object animation) {
                transitionAnimationStartTime = System.currentTimeMillis();
              }

              @Override
              public void onAnimationEnd(Object animation) {
                onAnimationEndCheck(false);
              }

              @Override
              public void onAnimationCancel(Object animation) {
                onAnimationEndCheck(false);
              }
            });
        currentAnimation.start();
      }
    } else {
      if (backgroundView != null) {
        ViewProxy.setAlpha(backgroundView, 1.0f);
        backgroundView.setVisibility(VISIBLE);
      }
      fragment.onOpenAnimationEnd();
    }
    return true;
  }