android.support.v4.app.FragmentManager.BackStackEntry Java Examples

The following examples show how to use android.support.v4.app.FragmentManager.BackStackEntry. 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: BrowseSupportFragment.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
@Override
public void onBackStackChanged() {
    if (getFragmentManager() == null) {
        Log.w(TAG, "getFragmentManager() is null, stack:", new Exception());
        return;
    }
    int count = getFragmentManager().getBackStackEntryCount();
    // if backstack is growing and last pushed entry is "headers" backstack,
    // remember the index of the entry.
    if (count > mLastEntryCount) {
        BackStackEntry entry = getFragmentManager().getBackStackEntryAt(count - 1);
        if (mWithHeadersBackStackName.equals(entry.getName())) {
            mIndexOfHeadersBackStack = count - 1;
        }
    } else if (count < mLastEntryCount) {
        // if popped "headers" backstack, initiate the show header transition if needed
        if (mIndexOfHeadersBackStack >= count) {
            mIndexOfHeadersBackStack = -1;
            if (!mShowingHeaders) {
                startHeadersTransitionInternal(true);
            }
        }
    }
    mLastEntryCount = count;
}
 
Example #2
Source File: FileChooserActivity.java    From qiniu-lab-android with MIT License 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onBackStackChanged() {

    int count = mFragmentManager.getBackStackEntryCount();
    if (count > 0) {
        BackStackEntry fragment = mFragmentManager
                .getBackStackEntryAt(count - 1);
        mPath = fragment.getName();
    } else {
        mPath = EXTERNAL_BASE_PATH;
    }

    setTitle(mPath);
    if (HAS_ACTIONBAR)
        invalidateOptionsMenu();
}
 
Example #3
Source File: RMBTMainActivity.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
public Fragment getCurrentFragment()
{
	final int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount();
    if (backStackEntryCount > 0)
    {
		try
        {
            final BackStackEntry backStackEntryAt = getSupportFragmentManager().getBackStackEntryAt(backStackEntryCount - 1);
            String fragmentTag = backStackEntryAt.getName();
            Fragment currentFragment = getSupportFragmentManager().findFragmentByTag(fragmentTag);
            return currentFragment;
        }
        catch (Exception e)
        {
            // fix possible race condition:
            // when called in background thread - back stack could be different between call of
            // getBackStackEntryCount() and getBackStackEntryAt()
            e.printStackTrace();
        }
	}
	
	return getSupportFragmentManager().findFragmentByTag(AppConstants.PAGE_TITLE_MAIN);
}
 
Example #4
Source File: BrowseSupportFragment.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
private void startHeadersTransitionInternal(final boolean withHeaders) {
    if (getFragmentManager().isDestroyed()) {
        return;
    }
    mShowingHeaders = withHeaders;
    mRowsSupportFragment.onExpandTransitionStart(!withHeaders, new Runnable() {
        @Override
        public void run() {
            mHeadersSupportFragment.onTransitionStart();
            createHeadersTransition();
            if (mBrowseTransitionListener != null) {
                mBrowseTransitionListener.onHeadersTransitionStart(withHeaders);
            }
            sTransitionHelper.runTransition(withHeaders ? mSceneWithHeaders : mSceneWithoutHeaders,
                    mHeadersTransition);
            if (mHeadersBackStackEnabled) {
                if (!withHeaders) {
                    getFragmentManager().beginTransaction()
                            .addToBackStack(mWithHeadersBackStackName).commit();
                } else {
                    int index = mBackStackChangedListener.mIndexOfHeadersBackStack;
                    if (index >= 0) {
                        BackStackEntry entry = getFragmentManager().getBackStackEntryAt(index);
                        getFragmentManager().popBackStackImmediate(entry.getId(),
                                FragmentManager.POP_BACK_STACK_INCLUSIVE);
                    }
                }
            }
        }
    });
}
 
Example #5
Source File: FileChooserActivity.java    From droid-stealth with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBackStackChanged() {

    int count = mFragmentManager.getBackStackEntryCount();
    if (count > 0) {
        BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
        mPath = fragment.getName();
    } else {
        mPath = EXTERNAL_BASE_PATH;
    }

    setTitle(mPath);
    if (HAS_ACTIONBAR)
        supportInvalidateOptionsMenu();
}
 
Example #6
Source File: FileChooserActivity.java    From filechooser with MIT License 5 votes vote down vote up
@Override
public void onBackStackChanged() {

    int count = mFragmentManager.getBackStackEntryCount();
    if (count > 0) {
        BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
        mPath = fragment.getName();
    } else {
        mPath = EXTERNAL_BASE_PATH;
    }

    setTitle(mPath);
    if (HAS_ACTIONBAR)
        invalidateOptionsMenu();
}
 
Example #7
Source File: FileChooserActivity.java    From secrecy with Apache License 2.0 5 votes vote down vote up
@Override
public void onBackStackChanged() {

    int count = mFragmentManager.getBackStackEntryCount();
    if (count > 0) {
        BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
        mPath = fragment.getName();
    } else {
        mPath = EXTERNAL_BASE_PATH;
    }

    setTitle(mPath);
    if (HAS_ACTIONBAR)
        supportInvalidateOptionsMenu();
}
 
Example #8
Source File: FileChooserActivity.java    From Readily with MIT License 5 votes vote down vote up
@Override
public void onBackStackChanged() {

    int count = mFragmentManager.getBackStackEntryCount();
    if (count > 0) {
        BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1);
        mPath = fragment.getName();
    } else {
        mPath = EXTERNAL_BASE_PATH;
    }

    setTitle(mPath);
    if (HAS_ACTIONBAR)
        invalidateOptionsMenu();
}
 
Example #9
Source File: FragmentManagerImpl.java    From letv with Apache License 2.0 4 votes vote down vote up
public BackStackEntry getBackStackEntryAt(int index) {
    return (BackStackEntry) this.mBackStack.get(index);
}