Java Code Examples for android.support.v4.app.FragmentTransaction#setBreadCrumbTitle()

The following examples show how to use android.support.v4.app.FragmentTransaction#setBreadCrumbTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsActivity.java    From AcDisplay with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Switch to a specific Fragment with taking care of validation, Title and BackStack
 */
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
                                  boolean addToBackStack, int titleResId, CharSequence title,
                                  boolean withTransition) {
    if (validate && !isValidFragment(fragmentName)) {
        String message = "Invalid fragment for this activity: " + fragmentName;
        throw new IllegalArgumentException(message);
    }

    Fragment f = Fragment.instantiate(this, fragmentName, args);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(android.R.id.content, f);

    if (withTransition && Device.hasKitKatApi())
        TransitionManager.beginDelayedTransition(mContent);
    if (addToBackStack) transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
    if (titleResId > 0) {
        transaction.setBreadCrumbTitle(titleResId);
    } else if (title != null) {
        transaction.setBreadCrumbTitle(title);
    }

    transaction.commitAllowingStateLoss();
    getFragmentManager().executePendingTransactions();
    return f;
}
 
Example 2
Source File: SettingsActivity.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Switch to a specific Fragment with taking care of validation, Title and BackStack
 */
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
                                  boolean addToBackStack, int titleResId, CharSequence title,
                                  boolean withTransition) {
    if (validate && !isValidFragment(fragmentName)) {
        String message = "Invalid fragment for this activity: " + fragmentName;
        throw new IllegalArgumentException(message);
    }

    Fragment f = Fragment.instantiate(this, fragmentName, args);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.main_content, f);

    if (withTransition && Device.hasKitKatApi())
        TransitionManager.beginDelayedTransition(mContent);
    if (addToBackStack) transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
    if (titleResId > 0) {
        transaction.setBreadCrumbTitle(titleResId);
    } else if (title != null) {
        transaction.setBreadCrumbTitle(title);
    }

    transaction.commitAllowingStateLoss();
    getFragmentManager().executePendingTransactions();
    return f;
}
 
Example 3
Source File: FragmentEventReceiver.java    From pandroid with Apache License 2.0 4 votes vote down vote up
@Override
protected void onOpenerReceived(FragmentOpener fragmentOpener) {

    if (clearBackStack) {
        clearBackStack();
    }


    Fragment fragment = getFragment(fragmentOpener);
    if (fragment == null) {
        return;
    }

    T attachedObject = refAttachedObject.get();

    if (attachedObject == null) {
        return;
    }


    FragmentTransaction trans = ((T) attachedObject).provideFragmentManager().beginTransaction();
    if (anim != null && anim.length > 3)
        trans.setCustomAnimations(anim[0], anim[1], anim[2], anim[3]);

    if (backStackTag != null) {
        trans.addToBackStack(backStackTag);
    }

    if (fragmentOpener.getTitle() != null) {
        trans.setBreadCrumbTitle(fragmentOpener.getTitle());
    } else if (defaultBreadcrumbTitle != null) {
        trans.setBreadCrumbTitle(defaultBreadcrumbTitle);
    }

    boolean handled = onExecuteFragmentTransaction(fragmentOpener, fragment, trans);
    if (!handled) {
        if (fragment instanceof DialogFragment) {
            ((DialogFragment) fragment).show(trans, fragmentTag);
        } else {
            trans.replace(fragmentContainerId, fragment, fragmentTag);
            try {
                trans.commit();
            } catch (IllegalStateException e) {
                Log.w(TAG, "Commit failed", e);
            }
        }
    }


}
 
Example 4
Source File: PreferenceActivity.java    From PreferenceFragment with Apache License 2.0 4 votes vote down vote up
/**
 * Start a new fragment containing a preference panel. If the preferences
 * are being displayed in multi-pane mode, the given fragment class will
 * be instantiated and placed in the appropriate pane. If running in
 * single-pane mode, a new activity will be launched in which to show the
 * fragment.
 * 
 * @param fragmentClass
 *            Full name of the class implementing the fragment.
 * @param args
 *            Any desired arguments to supply to the fragment.
 * @param titleRes
 *            Optional resource identifier of the title of this
 *            fragment.
 * @param titleText
 *            Optional text of the title of this fragment.
 * @param resultTo
 *            Optional fragment that result data should be sent to.
 *            If non-null, resultTo.onActivityResult() will be called when this
 *            preference panel is done. The launched panel must use
 *            {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
 * @param resultRequestCode
 *            If resultTo is non-null, this is the caller's
 *            request code to be received with the resut.
 */
public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
        CharSequence titleText, Fragment resultTo, int resultRequestCode) {
    if (mSinglePane) {
        startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
    } else {
        Fragment f = Fragment.instantiate(this, fragmentClass, args);
        if (resultTo != null) {
            f.setTargetFragment(resultTo, resultRequestCode);
        }
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.prefs, f);
        if (titleRes != 0) {
            transaction.setBreadCrumbTitle(titleRes);
        } else if (titleText != null) {
            transaction.setBreadCrumbTitle(titleText);
        }
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(BACK_STACK_PREFS);
        transaction.commitAllowingStateLoss();
    }
}