app/src/main/java/com/cabify/getaride/presentation/view/activity/BaseActivity.java
/**
     * Adds a {@link Fragment} to this activity's layout.
     *
     * @param containerViewId The container view to where add the fragment.
     * @param fragment The fragment to be added.
     * @param isLastFragmentInFlow Define if the activity container will close when back button is pressed. If 'yes' the activity will close then this fragment is shwon and the back button is pressed
     * @param duplicateFragment Define if the fragment will be duplicated even if the current fragment shown is the same type. If 'false' and current fragment is the same type no new fragment will be created. Note: implemented for the Content Details Fragment to be able to show several fragments in a row.
     */
Adds a  Fragment to this activity's layout.
@param containerViewId The container view to where add the fragment.
@param fragment The fragment to be added.
@param isLastFragmentInFlow Define if the activity container will close when back button is pressed. If 'yes' the activity will close then this fragment is shwon and the back button is pressed
@param duplicateFragment Define if the fragment will be duplicated even if the current fragment shown is the same type. If 'false' and current fragment is the same type no new fragment will be created. Note: implemented for the Content Details Fragment to be able to show several fragments in a row.
Adds a Fragment to this activity ' s layout . @param containerViewId The container view to where add the fragment . @param fragment The fragment to be added . @param isLastFragmentInFlow Define if the activity container will close when back button is pressed . If ' yes ' the activity will close then this fragment is shwon and the back button is pressed @param duplicateFragment Define if the fragment will be duplicated even if the current fragment shown is the same type . If ' false ' and current fragment is the same type no new fragment will be created . Note : implemented for the Content Details Fragment to be able to show several fragments in a row .
protected void addFragment(int containerViewId, Fragment fragment, boolean isLastFragmentInFlow, boolean duplicateFragment) {
        if(isLastFragmentInFlow) {
            this.getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        }
        String fragmentTag = fragment.getClass().getSimpleName();
        boolean fragmentPopped = this.getFragmentManager().popBackStackImmediate(fragmentTag, 0);
        if(!fragmentPopped) {
            FragmentTransaction fragmentTransaction = this.getFragmentManager().beginTransaction();
            if(this.getFragmentManager().findFragmentByTag(fragmentTag) == null || duplicateFragment || !isCurrentFragment(fragment)) {
                if(!isLastFragmentInFlow) {
                    fragmentTransaction.addToBackStack(fragment.getClass().getSimpleName());
                }
                fragmentTransaction.replace(containerViewId, fragment, fragmentTag);
                fragmentTransaction.commit();
            }
        }
    }
protected void addFragment ( int containerViewId , Fragment fragment , boolean isLastFragmentInFlow , boolean duplicateFragment ) { if ( isLastFragmentInFlow ) { this . getFragmentManager ( ) . popBackStack ( null , FragmentManager . POP_BACK_STACK_INCLUSIVE ) ; } String fragmentTag = fragment . getClass ( ) . getSimpleName ( ) ; boolean fragmentPopped = this . getFragmentManager ( ) . popBackStackImmediate ( fragmentTag , 0 ) ; if ( ! fragmentPopped ) { FragmentTransaction fragmentTransaction = this . getFragmentManager ( ) . beginTransaction ( ) ; if ( this . getFragmentManager ( ) . findFragmentByTag ( fragmentTag ) == null || duplicateFragment || ! isCurrentFragment ( fragment ) ) { if ( ! isLastFragmentInFlow ) { fragmentTransaction . addToBackStack ( fragment . getClass ( ) . getSimpleName ( ) ) ; } fragmentTransaction . replace ( containerViewId , fragment , fragmentTag ) ; fragmentTransaction . commit ( ) ; } } }
Adds a {@link Fragment} to this activity's layout.
Adds a { @link Fragment } to this activity ' s layout .
// Clean all the back stack if we are showing a final fragment // Replace fragment is it is not in the back stack or it is not current fragment