Created
August 28, 2019 03:25
-
-
Save milaptank/d922ed90fb60637397bf055cdae6128e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void startFragment(FragmentTransaction fragmentTransaction, BaseFragment fragment, | |
boolean withAnimation, boolean withBackStack, int fragmentContainerId) { | |
if (withAnimation) { | |
fragmentTransaction.setCustomAnimations(R.anim.fragment_slide_in_left, | |
R.anim.fragment_slide_out_left, R.anim.fragment_slide_in_right, | |
R.anim.fragment_slide_out_right); | |
} | |
fragmentTransaction.replace(fragmentContainerId, fragment, fragment.getTagText()); | |
if (withBackStack) { | |
fragmentTransaction.addToBackStack(fragment.getTagText()); | |
} | |
fragmentTransaction.commit(); | |
} | |
public static void startFragment(FragmentTransaction fragmentTransaction, BaseFragment fragment, | |
boolean withAnimation, String tag, int fragmentContainerId) { | |
if (withAnimation) { | |
fragmentTransaction.setCustomAnimations(R.anim.fragment_slide_in_left, | |
R.anim.fragment_slide_out_left, R.anim.fragment_slide_in_right, | |
R.anim.fragment_slide_out_right); | |
} | |
fragmentTransaction.replace(fragmentContainerId, fragment, fragment.getTagText()); | |
fragmentTransaction.addToBackStack(tag); | |
fragmentTransaction.commit(); | |
} | |
public static void popBackStack(FragmentManager fragmentManager) { | |
fragmentManager.popBackStackImmediate(); | |
} | |
public static void popBackStackTillTag(FragmentManager fragmentManager, String tag) { | |
fragmentManager.popBackStackImmediate(tag, FragmentManager.POP_BACK_STACK_INCLUSIVE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment