Example usage for android.support.v4.app FragmentManager beginTransaction

List of usage examples for android.support.v4.app FragmentManager beginTransaction

Introduction

In this page you can find the example usage for android.support.v4.app FragmentManager beginTransaction.

Prototype

public abstract FragmentTransaction beginTransaction();

Source Link

Document

Start a series of edit operations on the Fragments associated with this FragmentManager.

Usage

From source file:cn.jarlen.richcommon.ui.FragmentStack.java

/**
 * put one fragment(which is contained by activity) into stack
 * @param context//from   www  .  ja v  a 2  s  .c  om
 * the activity
 * @param containerId
 * fragment containerId
 * @param newFragment
 * fragment object
 */
public static void addFragmentToStack(FragmentActivity context, int containerId, Fragment newFragment) {
    FragmentManager fragmentManager = context.getSupportFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(containerId, newFragment, newFragment.getClass().getSimpleName());
    ft.setCustomAnimations(anim_In, anim_out);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.addToBackStack(null);
    ft.commit();
}

From source file:cn.jarlen.richcommon.ui.FragmentStack.java

public static void addFrament(FragmentActivity context, int containerId, Fragment newFragment) {
    try {/*from w ww  .  j  a v a  2  s.c o m*/
        FragmentManager fragmentManager = context.getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        ft.setCustomAnimations(anim_In, anim_out);
        ft.add(containerId, newFragment, newFragment.getClass().getSimpleName()).commit();
    } catch (IllegalStateException e) {
        if (e.getMessage().startsWith("Fragment already added")) {
            removeFragment(context, newFragment);
            addFrament(context, containerId, newFragment);
        }
    }
}

From source file:com.burhan.rashid.daggermvprx.util.ActivityUtils.java

/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *///from   w w  w .  jav a 2 s  .  c om
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment,
        int frameId, String tag) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment, tag);
    transaction.commit();
}

From source file:com.burhan.rashid.daggermvprx.util.ActivityUtils.java

/**
 * The {@code fragment} is replace to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 *//*from  w  w  w .  ja  va  2s  . c  o m*/
public static void replaceFragmentToActivity(@NonNull FragmentManager fragmentManager,
        @NonNull Fragment fragment, int frameId, String tag) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(frameId, fragment, tag);
    transaction.commit();
}

From source file:com.burhan.rashid.daggermvprx.util.ActivityUtils.java

/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager} with BackStack.
 *//*  w  w  w.  j a v  a 2s . c o m*/
public static void addFragmentToActivityWithBackStack(@NonNull FragmentManager fragmentManager,
        @NonNull Fragment fragment, int frameId, String tag) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment, tag);
    transaction.addToBackStack(tag);
    transaction.commit();
}

From source file:com.burhan.rashid.daggermvprx.util.ActivityUtils.java

/**
 * The {@code fragment} is replace to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager} with BackStack.
 *//*from w  w w  .  j  av  a 2 s .  c  o  m*/
public static void replaceFragmentToActivityWithBackStack(@NonNull FragmentManager fragmentManager,
        @NonNull Fragment fragment, int frameId, String tag) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(frameId, fragment, tag);
    transaction.addToBackStack(tag);
    transaction.commit();
}

From source file:com.cylan.jiafeigou.utils.ActivityUtils.java

public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment,
        int containerId, int id) {
    fragmentManager.beginTransaction()
            .setCustomAnimations(R.anim.slide_down_in, R.anim.slide_down_out, R.anim.slide_down_in,
                    R.anim.slide_down_out)
            .add(containerId, fragment, fragment.getClass().getSimpleName())
            .addToBackStack(fragment.getClass().getSimpleName()).commit();
}

From source file:com.cylan.jiafeigou.utils.ActivityUtils.java

public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment,
        int containerId, boolean id) {
    fragmentManager.beginTransaction()
            .setCustomAnimations(R.anim.slide_down_in, R.anim.slide_out_left, R.anim.slide_in_left,
                    R.anim.slide_out_left)
            .add(containerId, fragment, fragment.getClass().getSimpleName()).commit();
}

From source file:com.deange.textfaker.ui.dialog.ConversationPersonDialog.java

public static void show(ConversationPersonDialog dialog, final Callback callback, final FragmentManager manager,
        final String personName, final String phoneNumber) {
    Log.v(TAG, "show()");

    final FragmentTransaction transaction = manager.beginTransaction();
    if (dialog != null) {
        transaction.remove(dialog);//from w  w w .  j a  va2  s.  c o m
    }

    dialog = ConversationPersonDialog.createInstance(personName, phoneNumber);
    dialog.setCallback(callback);
    dialog.show(transaction, ConversationPersonDialog.TAG);
}

From source file:com.conferenceengineer.android.iosched.util.WiFiUtils.java

public static void showWiFiDialog(FragmentActivity activity) {
    FragmentManager fm = activity.getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag("dialog_wifi");
    if (prev != null) {
        ft.remove(prev);//  ww w  .ja v a  2  s  .  co  m
    }
    ft.addToBackStack(null);

    Bundle arguments = new Bundle();
    arguments.putBoolean(WiFiDialog.WIFI_ENABLED_KEY, isWiFiEnabled(activity));
    WiFiDialog wifiDialog = new WiFiDialog();
    wifiDialog.setArguments(arguments);
    wifiDialog.show(ft, "dialog_wifi");
}