Breaking

Post Top Ad

Your Ad Spot

Wednesday, 8 May 2019

Fragment Executor

package com.example.anwar.politix.accessories;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import com.example.anwar.politix.R;

public class FragmentExecutor {

    public static void addFragment(FragmentManager fragmentManager, Fragment fragment) {
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.setCustomAnimations(R.anim.animation_enter_from_right, R.anim.animation_leave_out_to_left);
        fragmentTransaction.replace(R.id.frame, fragment);
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.commit();
    }

    public static void addChildFragment(FragmentManager fragmentManager, Fragment fragment) {
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.setCustomAnimations(R.anim.animation_enter_from_right, R.anim.animation_leave_out_to_left);
        fragmentTransaction.replace(R.id.frameChild, fragment);
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.commit();
    }

}

No comments:

Post a Comment