use of androidx.fragment.app.FragmentTransaction in project AndroidUtilCode by Blankj.
the class FragmentUtils method replace.
/**
* Replace fragment.
*
* @param fm The manager of fragment.
* @param fragment The new fragment to place in the container.
* @param containerId The id of container.
* @param destTag The destination of fragment's tag.
* @param isAddStack True to add fragment in stack, false otherwise.
* @param sharedElements A View in a disappearing Fragment to match with a View in an
* appearing Fragment.
*/
public static void replace(@NonNull final FragmentManager fm, @NonNull final Fragment fragment, @IdRes final int containerId, final String destTag, final boolean isAddStack, final View... sharedElements) {
FragmentTransaction ft = fm.beginTransaction();
putArgs(fragment, new Args(containerId, destTag, false, isAddStack));
addSharedElement(ft, sharedElements);
operate(TYPE_REPLACE_FRAGMENT, fm, ft, null, fragment);
}
use of androidx.fragment.app.FragmentTransaction in project AndroidUtilCode by Blankj.
the class FragmentUtils method replace.
/**
* Replace fragment.
*
* @param fm The manager of fragment.
* @param fragment The new fragment to place in the container.
* @param containerId The id of container.
* @param destTag The destination of fragment's tag.
* @param isAddStack True to add fragment in stack, false otherwise.
* @param enterAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being added or attached.
* @param exitAnim An animation or animator resource ID used for the exit animation on the
* view of the fragment being removed or detached.
* @param popEnterAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being readded or reattached caused by
* popBackStack() or similar methods.
* @param popExitAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being removed or detached caused by
* popBackStack() or similar methods.
*/
public static void replace(@NonNull final FragmentManager fm, @NonNull final Fragment fragment, @IdRes final int containerId, final String destTag, final boolean isAddStack, @AnimatorRes @AnimRes final int enterAnim, @AnimatorRes @AnimRes final int exitAnim, @AnimatorRes @AnimRes final int popEnterAnim, @AnimatorRes @AnimRes final int popExitAnim) {
FragmentTransaction ft = fm.beginTransaction();
putArgs(fragment, new Args(containerId, destTag, false, isAddStack));
addAnim(ft, enterAnim, exitAnim, popEnterAnim, popExitAnim);
operate(TYPE_REPLACE_FRAGMENT, fm, ft, null, fragment);
}
use of androidx.fragment.app.FragmentTransaction in project AndroidUtilCode by Blankj.
the class FragmentUtils method add.
/**
* Add fragment.
*
* @param fm The manager of fragment.
* @param add The fragment will be add.
* @param containerId The id of container.
* @param tag The tag of fragment.
* @param isAddStack True to add fragment in stack, false otherwise.
* @param enterAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being added or attached.
* @param exitAnim An animation or animator resource ID used for the exit animation on the
* view of the fragment being removed or detached.
* @param popEnterAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being readded or reattached caused by
* popBackStack() or similar methods.
* @param popExitAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being removed or detached caused by
* popBackStack() or similar methods.
*/
public static void add(@NonNull final FragmentManager fm, @NonNull final Fragment add, @IdRes final int containerId, final String tag, final boolean isAddStack, @AnimatorRes @AnimRes final int enterAnim, @AnimatorRes @AnimRes final int exitAnim, @AnimatorRes @AnimRes final int popEnterAnim, @AnimatorRes @AnimRes final int popExitAnim) {
FragmentTransaction ft = fm.beginTransaction();
putArgs(add, new Args(containerId, tag, false, isAddStack));
addAnim(ft, enterAnim, exitAnim, popEnterAnim, popExitAnim);
operate(TYPE_ADD_FRAGMENT, fm, ft, null, add);
}
use of androidx.fragment.app.FragmentTransaction in project FirebaseUI-Android by firebase.
the class AppCompatBase method switchFragment.
protected void switchFragment(@NonNull Fragment fragment, int fragmentId, @NonNull String tag, boolean withTransition, boolean addToBackStack) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (withTransition) {
ft.setCustomAnimations(R.anim.fui_slide_in_right, R.anim.fui_slide_out_left);
}
ft.replace(fragmentId, fragment, tag);
if (addToBackStack) {
ft.addToBackStack(null).commit();
} else {
ft.disallowAddToBackStack().commit();
}
}
use of androidx.fragment.app.FragmentTransaction in project FirebaseUI-Android by firebase.
the class EmailActivity method onNewUser.
@Override
public void onNewUser(User user) {
// New user, direct them to create an account with email/password
// if account creation is enabled in SignInIntentBuilder
TextInputLayout emailLayout = findViewById(R.id.email_layout);
AuthUI.IdpConfig emailConfig = ProviderUtils.getConfigFromIdps(getFlowParams().providers, EmailAuthProvider.PROVIDER_ID);
if (emailConfig == null) {
emailConfig = ProviderUtils.getConfigFromIdps(getFlowParams().providers, EMAIL_LINK_PROVIDER);
}
if (emailConfig.getParams().getBoolean(ExtraConstants.ALLOW_NEW_EMAILS, true)) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (emailConfig.getProviderId().equals(EMAIL_LINK_PROVIDER)) {
showRegisterEmailLinkFragment(emailConfig, user.getEmail());
} else {
RegisterEmailFragment fragment = RegisterEmailFragment.newInstance(user);
ft.replace(R.id.fragment_register_email, fragment, RegisterEmailFragment.TAG);
if (emailLayout != null) {
String emailFieldName = getString(R.string.fui_email_field_name);
ViewCompat.setTransitionName(emailLayout, emailFieldName);
ft.addSharedElement(emailLayout, emailFieldName);
}
ft.disallowAddToBackStack().commit();
}
} else {
emailLayout.setError(getString(R.string.fui_error_email_does_not_exist));
}
}
Aggregations