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: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);/*from   w w  w  .  j a  va  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");
}

From source file:org.kaaproject.kaa.demo.photoframe.util.Utils.java

public static Fragment getTopFragment(FragmentActivity activity) {
    if (activity == null) {
        Log.e(TAG, "Unable to get top fragment. Invalid args.");
        return null;
    }//from  w ww  .  j  av  a 2 s  .  co  m

    FragmentManager fm = activity.getSupportFragmentManager();
    if (fm.getBackStackEntryCount() > 0) {
        FragmentManager.BackStackEntry entry = fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1);
        return fm.findFragmentByTag(entry.getName());
    }
    return null;
}

From source file:com.github.pockethub.ui.DialogFragmentHelper.java

/**
 * Show dialog/*from   w  ww  . j  ava  2  s. c  o  m*/
 *
 * @param activity
 * @param fragment
 * @param arguments
 * @param tag
 */
protected static void show(FragmentActivity activity, DialogFragmentHelper fragment, Bundle arguments,
        String tag) {
    FragmentManager manager = activity.getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    Fragment current = manager.findFragmentByTag(tag);
    if (current != null)
        transaction.remove(current);
    transaction.addToBackStack(null);

    fragment.setArguments(arguments);
    fragment.show(manager, tag);
}

From source file:com.github.pockethub.android.ui.DialogFragmentHelper.java

/**
 * Show dialog/*from w  w w  .j  a va2  s  . com*/
 *
 * @param activity
 * @param fragment
 * @param arguments
 * @param tag
 */
protected static void show(FragmentActivity activity, DialogFragmentHelper fragment, Bundle arguments,
        String tag) {
    FragmentManager manager = activity.getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    Fragment current = manager.findFragmentByTag(tag);
    if (current != null) {
        transaction.remove(current);
    }
    transaction.addToBackStack(null);

    fragment.setArguments(arguments);
    fragment.show(manager, tag);
}

From source file:org.alfresco.mobile.android.application.extension.samsung.utils.SNoteUtils.java

public static boolean processUnsupportedException(final FragmentActivity activity, SsdkUnsupportedException e) {
    e.printStackTrace();/*  ww  w . ja  va2  s.c  o  m*/
    int errType = e.getType();
    SNoteSDKDialogFragment.newInstance(errType).show(activity.getSupportFragmentManager(),
            SNoteSDKDialogFragment.TAG);
    if (errType == SsdkUnsupportedException.LIBRARY_UPDATE_IS_RECOMMENDED) {
        return false;
    }
    return true;
}

From source file:com.tomeokin.lspush.ui.navigator.Navigator.java

public static void moveTo(FragmentActivity base, Class<? extends Fragment> fragment, Bundle args, @IdRes int id,
        boolean addToBackStack) {
    moveTo(base, base.getSupportFragmentManager(), fragment, args, id, addToBackStack);
}

From source file:de.dev.eth0.rssreader.app.util.ActivityStarterHelper.java

/**
 * displays the given feed//from w w w.j  a  va2 s .  c o m
 *
 * @param id
 * @param context
 */
public static void displayFeedEntry(Context context, Long id) {
    if (context instanceof FragmentActivity) {
        FragmentActivity activity = (FragmentActivity) context;
        // Depending on the design, we either update the FeedEntryFragment or start a new activity
        FeedEntryFragment feedEntryFragment = (FeedEntryFragment) activity.getSupportFragmentManager()
                .findFragmentById(R.id.feed_detail);
        if (feedEntryFragment != null && feedEntryFragment.isAdded()) {
            Timber.d("Updating feedEntryFragment %d", id);
            feedEntryFragment.displayFeedEntry(id);
        } else {
            Timber.d("Starting FeedEntryDetailActivity for Feed %d", id);
            activity.startActivity(
                    new Intent(context, FeedEntryDetailActivity.class).putExtra(FeedEntryTable.COLUMN_ID, id));
        }
    } else {
        Timber.e("Could not display feed entry as the context has the wrong class %s", context.getClass());
    }
}

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

public static void replaceFragment(FragmentActivity context, int containerId, Fragment newFragment) {
    FragmentManager fragmentManager = context.getSupportFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.setCustomAnimations(anim_In, anim_out);
    ft.replace(containerId, newFragment, newFragment.getClass().getSimpleName());
    // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.commit();/*from  w ww .  java  2 s. c  o m*/
}

From source file:com.yek.keyboard.ui.settings.MainSettingsActivity.java

/**
 * Will set the title in the hosting Activity's title.
 * Will only set the title if the fragment is hosted by the Activity's manager, and not inner one.
 *///from  w w  w. ja v  a 2  s  .co m
public static void setActivityTitle(Fragment fragment, CharSequence title) {
    FragmentActivity activity = fragment.getActivity();
    if (activity.getSupportFragmentManager() == fragment.getFragmentManager()) {
        activity.setTitle(title);
    }
}

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

/**
 * put one fragment(which is contained by activity) into stack
 * @param context/*from w w  w.ja  va  2s.  c  o m*/
 * 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();
}