Search in sources :

Example 36 with FragmentTransaction

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);
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction)

Example 37 with FragmentTransaction

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);
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction)

Example 38 with FragmentTransaction

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);
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction)

Example 39 with FragmentTransaction

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();
    }
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction)

Example 40 with FragmentTransaction

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));
    }
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AuthUI(com.firebase.ui.auth.AuthUI)

Aggregations

FragmentTransaction (androidx.fragment.app.FragmentTransaction)176 Fragment (androidx.fragment.app.Fragment)57 FragmentManager (androidx.fragment.app.FragmentManager)53 Bundle (android.os.Bundle)25 Test (org.junit.Test)14 DialogFragment (androidx.fragment.app.DialogFragment)10 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)6 View (android.view.View)5 Intent (android.content.Intent)4 ActionBar (androidx.appcompat.app.ActionBar)4 Toolbar (androidx.appcompat.widget.Toolbar)4 SwipeRefreshListFragment (eu.siacs.conversations.ui.widget.SwipeRefreshListFragment)4 MediaGalleryFragment (org.thoughtcrime.securesms.mediasend.v2.gallery.MediaGalleryFragment)4 SuppressLint (android.annotation.SuppressLint)3 Activity (android.app.Activity)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 SslUntrustedCertDialog (com.owncloud.android.ui.dialog.SslUntrustedCertDialog)3 TargetApi (android.annotation.TargetApi)2 PreferenceFrameLayout (android.preference.PreferenceFrameLayout)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2