Example usage for android.support.v4.app FragmentActivity getSupportFragmentManager

List of usage examples for android.support.v4.app FragmentActivity getSupportFragmentManager

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity getSupportFragmentManager.

Prototype

public FragmentManager getSupportFragmentManager() 

Source Link

Document

Return the FragmentManager for interacting with fragments associated with this activity.

Usage

From source file:org.mariotaku.twidere.fragment.MessageDialogFragment.java

public static MessageDialogFragment show(FragmentActivity activity, String message, String tag) {
    MessageDialogFragment df = new MessageDialogFragment();
    Bundle args = new Bundle();
    args.putString(EXTRA_MESSAGE, message);
    df.setArguments(args);/*from w  w w. j a  v  a 2 s. c om*/
    df.show(activity.getSupportFragmentManager(), tag);
    return df;
}

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

public static void addFrament(FragmentActivity context, int containerId, Fragment newFragment) {
    try {//from ww  w .  j  a v  a  2  s  .co  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.ntsync.android.sync.activities.MessageDialog.java

/**
 * Show Message Dialog from a Text and Activity
 * /* w  w w .j  a v a 2 s .c o m*/
 * @param text
 * @param fragmentActivity
 * @return
 */
public static MessageDialog show(CharSequence text, FragmentActivity fragmentActivity) {
    return show(text, fragmentActivity.getSupportFragmentManager());
}

From source file:eu.inmite.apps.smsjizdenka.dialog.EulaDialogFragment.java

public static void show(FragmentActivity activity, Fragment targetFragment, int requestCode,
        boolean openedFromAbout) {
    EulaDialogFragment eulaDialogFragment = (EulaDialogFragment) activity.getSupportFragmentManager()
            .findFragmentByTag(TAG);//from ww w. j  a va2  s.  c  o  m
    if (eulaDialogFragment != null) {
        eulaDialogFragment.dismiss();
    }

    EulaDialogFragment d = new EulaDialogFragment();
    d.setTargetFragment(targetFragment, requestCode);
    Bundle bundle = new Bundle();
    bundle.putBoolean(ARG_OPENED_FROM_ABOUT, openedFromAbout);
    d.setArguments(bundle);
    d.show(activity.getSupportFragmentManager(), TAG);
}

From source file:com.getchute.android.photopickerplus.util.FragmentUtil.java

public static void replaceContentWithRootFragment(FragmentActivity activity, AccountModel account,
        PhotoFilterType filterType, List<Integer> accountItemPositions, List<Integer> imageItemPositions,
        List<Integer> videoItemPositions) {
    FragmentTransaction fragmentTransaction = activity.getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.gcFragments, FragmentRoot.newInstance(account, filterType,
            accountItemPositions, imageItemPositions, videoItemPositions), TAG_FRAGMENT_FOLDER);
    fragmentTransaction.commit();/*from ww  w. j a  va  2  s . c om*/
}

From source file:org.mariotaku.twidere.fragment.support.SupportMessageDialogFragment.java

public static SupportMessageDialogFragment show(FragmentActivity activity, String message, String tag) {
    SupportMessageDialogFragment df = new SupportMessageDialogFragment();
    Bundle args = new Bundle();
    args.putString(EXTRA_MESSAGE, message);
    df.setArguments(args);//from ww w .j  a  v  a2  s.c o  m
    df.show(activity.getSupportFragmentManager(), tag);
    return df;
}

From source file:com.google.android.apps.santatracker.games.PlayGamesFragment.java

/**
 * Get or create an instance of the Fragment attached to an Activity.
 * @param activity FragmentActivity to host the Fragment.
 * @param listener SignInListener to respond to changes in sign-in state.
 * @return instance of PlayGamesFragment.
 *///from w  w  w . j a va 2 s.c  om
public static PlayGamesFragment getInstance(FragmentActivity activity, SignInListener listener) {

    FragmentManager fm = activity.getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();

    PlayGamesFragment result = null;

    Fragment fragment = fm.findFragmentByTag(FRAGMENT_TAG);
    if (fragment == null) {
        result = new PlayGamesFragment();
        ft.add(result, FRAGMENT_TAG).disallowAddToBackStack().commit();
    } else {
        result = (PlayGamesFragment) fragment;
    }

    result.setListener(listener);
    return result;
}

From source file:com.ntsync.android.sync.activities.MessageDialog.java

private static MessageDialog showDialog(Bundle args, FragmentActivity activity, String dialogId) {
    return showDialog(args, activity.getSupportFragmentManager(), dialogId);
}

From source file:Main.java

/**
 * This method clears backstack and loads fragment in a root.
 * //w  w  w. ja  v  a 2  s  .c  o m
 * @param fragmentActivity
 * @param fragmentContainerId
 * @param fragmentClass
 * @param bundle
 * @param tag
 * @return true if loaded successfully, false otherwise
 */
public static boolean loadFragmentInRoot(FragmentActivity fragmentActivity, int fragmentContainerId,
        Class<? extends Fragment> fragmentClass, Bundle bundle, String tag) {
    // TODO Auto-generated method stub
    boolean status = false;

    FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager();
    // remove all fragments from back stack
    fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    // add new fragment
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
            android.R.anim.fade_in, android.R.anim.fade_out);
    Fragment fragment;
    try {
        fragment = fragmentClass.newInstance();
        fragment.setArguments(bundle);
        fragmentTransaction.replace(fragmentContainerId, fragment, tag).commit();
        // finish pending transactions
        fragmentManager.executePendingTransactions();
        status = true;
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return status;
}

From source file:com.example.nitish.welcomapp.utilitypt.CommonMenuHandler.java

/**
 * Select an action based on a menu selection.
 *
 * @param activity The calling Activity/*w ww.j a v  a 2 s. c  om*/
 * @param id       Menu item ID
 * @return Whether the menu selection was handled
 */
public static boolean handleSelect(@NonNull FragmentActivity activity, int id) {
    switch (id) {
    case R.id.menu_settings:
        activity.startActivity(new Intent(activity, SettingsActivity.class));
        return true;
    case R.id.menu_about:
        AboutFragment.showDialog(activity.getSupportFragmentManager());
        return true;
    }
    return false;
}