本文整理汇总了Java中android.support.v4.app.FragmentManager.BackStackEntry类的典型用法代码示例。如果您正苦于以下问题:Java BackStackEntry类的具体用法?Java BackStackEntry怎么用?Java BackStackEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BackStackEntry类属于android.support.v4.app.FragmentManager包,在下文中一共展示了BackStackEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentFragment
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
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);
}
示例2: onBackStackChanged
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@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;
}
示例3: onBackStackChanged
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@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();
}
示例4: onClick
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@Override
public void onClick(View v) {
if (v.getTag() instanceof BackStackEntry) {
BackStackEntry bse = (BackStackEntry) v.getTag();
if (bse == mParentEntry) {
if (mParentClickListener != null) {
mParentClickListener.onClick(v);
}
} else {
if (mOnBreadCrumbClickListener != null) {
if (mOnBreadCrumbClickListener.onBreadCrumbClick(
bse == mTopEntry ? null : bse, 0)) {
return;
}
}
if (bse == mTopEntry) {
mActivity.getSupportFragmentManager().popBackStack();
} else {
mActivity.getSupportFragmentManager().popBackStack(
bse.getId(), 0);
}
}
}
}
示例5: getTopFragment
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
/**
* Get latest attached fragment from {@link FragmentManager}
* @return Latest attached Fragment
*/
public Fragment getTopFragment() {
FragmentManager fragMgr = getSupportFragmentManager();
if (fragMgr.getBackStackEntryCount() == 0) {
return null;
}
FragmentManager.BackStackEntry backEntry = fragMgr.getBackStackEntryAt(fragMgr.getBackStackEntryCount() - 1);
String backEntryName = backEntry.getName();
return fragMgr.findFragmentByTag(backEntryName);
}
示例6: onBackStackChanged
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@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();
}
示例7: onBackStackChanged
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
public void onBackStackChanged() {
path = EXTERNAL_BASE_PATH;
int count = fragmentManager.getBackStackEntryCount();
if (count > 0) {
BackStackEntry fragment = fragmentManager.getBackStackEntryAt(count - 1);
path = fragment.getName();
}
setTitle(path);
}
示例8: startHeadersTransitionInternal
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
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);
}
}
}
}
});
}
示例9: onBackStackChanged
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@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);
supportInvalidateOptionsMenu();
}
示例10: onBackStackChanged
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@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();
}
示例11: createBackStackEntry
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
private BackStackEntry createBackStackEntry(final CharSequence title,
final CharSequence shortTitle) {
if (title == null) {
return null;
}
return new BackStackEntry() {
@Override
public CharSequence getBreadCrumbShortTitle() {
return shortTitle;
}
@Override
public int getBreadCrumbShortTitleRes() {
return 0;
}
@Override
public CharSequence getBreadCrumbTitle() {
return title;
}
@Override
public int getBreadCrumbTitleRes() {
return 0;
}
@Override
public int getId() {
return 2837452;
}
@Override
public String getName() {
return "backstackentry";
}
};
}
示例12: getPreEntry
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
private BackStackEntry getPreEntry(int index) {
if (mParentEntry != null) {
return index == 0 ? mParentEntry : mTopEntry;
} else {
return mTopEntry;
}
}
示例13: onBackPressed
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@Override
public void onBackPressed() {
FragmentManager mgr = getSupportFragmentManager();
int idxLast = mgr.getBackStackEntryCount() - 2;
if(idxLast < 0) {
this.setResult(RESULT_OK);
finish();
} else {
BackStackEntry entry = mgr.getBackStackEntryAt(idxLast);
swapToFragmentView(ScreenList.valueOf(entry.getName()));
}
}
示例14: createBackStackEntry
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
private BackStackEntry createBackStackEntry(final CharSequence title,
final CharSequence shortTitle) {
if (title == null) {
return null;
}
return new BackStackEntry() {
@Override
public CharSequence getBreadCrumbShortTitle() {
return shortTitle;
}
@Override
public int getBreadCrumbShortTitleRes() {
return 0;
}
@Override
public CharSequence getBreadCrumbTitle() {
return title;
}
@Override
public int getBreadCrumbTitleRes() {
return 0;
}
@Override
public int getId() {
return 2837452;
}
@Override
public String getName() {
return "backstackentry";
}
};
}
示例15: onBackStackChanged
import android.support.v4.app.FragmentManager.BackStackEntry; //导入依赖的package包/类
@Override
public void onBackStackChanged() {
mPath = EXTERNAL_BASE_PATH;
int count = mFragmentManager.getBackStackEntryCount();
if (count > 0) {
BackStackEntry fragment = mFragmentManager
.getBackStackEntryAt(count - 1);
mPath = fragment.getName();
}
setTitle(mPath);
}