本文整理了Java中androidx.fragment.app.FragmentManager.getBackStackEntryCount()
方法的一些代码示例,展示了FragmentManager.getBackStackEntryCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentManager.getBackStackEntryCount()
方法的具体详情如下:
包路径:androidx.fragment.app.FragmentManager
类名称:FragmentManager
方法名:getBackStackEntryCount
暂无
代码示例来源:origin: westnordost/StreetComplete
@Override public void onBackPressed() {
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
getSupportFragmentManager().popBackStack();
} else {
super.onBackPressed();
}
}
代码示例来源:origin: WireGuard/wireguard-android
@Override public void onBackStackChanged() {
if (actionBar == null)
return;
// Do not show the home menu when the two-pane layout is at the detail view (see above).
final int backStackEntries = getSupportFragmentManager().getBackStackEntryCount();
final int minBackStackEntries = isTwoPaneLayout ? 2 : 1;
actionBar.setDisplayHomeAsUpEnabled(backStackEntries >= minBackStackEntries);
}
代码示例来源:origin: KDE/kdeconnect-android
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
FragmentManager fm = getSupportFragmentManager();
if (fm.getBackStackEntryCount() > 0) {
fm.popBackStack();
return true;
}
}
return super.onOptionsItemSelected(item);
}
代码示例来源:origin: saki4510t/libcommon
@Override
public void onBackPressed() {
if (DEBUG) Log.v(TAG, "onBackPressed:");
// Fragment内の子Fragmentを切り替えた時にbackキーを押すと
// Fragment自体がpopBackされてしまうのに対するworkaround
final FragmentManager fm = getSupportFragmentManager();
final Fragment fragment = fm.findFragmentById(R.id.container);
if (fragment instanceof BaseFragment) {
final FragmentManager child_fm = fragment.getChildFragmentManager();
if (child_fm.getBackStackEntryCount() > 0) {
// HomeFragmentの子Fragmentがバックスタックに有る時はそれをpopBackする
child_fm.popBackStack();
return;
}
if (((BaseFragment) fragment).onBackPressed()) {
return;
}
}
super.onBackPressed();
}
代码示例来源:origin: andstatus/andstatus
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (isRootScreen()) {
closeAndRestartApp();
} else if(getSupportFragmentManager().getBackStackEntryCount() > 0) {
getSupportFragmentManager().popBackStack();
} else {
finish();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
代码示例来源:origin: WireGuard/wireguard-android
@Override
public void onBackPressed() {
final int backStackEntries = getSupportFragmentManager().getBackStackEntryCount();
// If the action menu is visible and expanded, collapse it instead of navigating back.
if (isTwoPaneLayout || backStackEntries == 0) {
if (listFragment != null && listFragment.collapseActionMenu())
return;
}
// If the two-pane layout does not have an editor open, going back should exit the app.
if (isTwoPaneLayout && backStackEntries <= 1) {
finish();
return;
}
// Deselect the current tunnel on navigating back from the detail pane to the one-pane list.
if (!isTwoPaneLayout && backStackEntries == 1) {
setSelectedTunnel(null);
return;
}
super.onBackPressed();
}
代码示例来源:origin: WireGuard/wireguard-android
@Override
protected void onSelectedTunnelChanged(@Nullable final Tunnel oldTunnel,
@Nullable final Tunnel newTunnel) {
final FragmentManager fragmentManager = getSupportFragmentManager();
final int backStackEntries = fragmentManager.getBackStackEntryCount();
if (newTunnel == null) {
// Clear everything off the back stack (all editors and detail fragments).
fragmentManager.popBackStackImmediate(0, FragmentManager.POP_BACK_STACK_INCLUSIVE);
return;
}
if (backStackEntries == 2) {
// Pop the editor off the back stack to reveal the detail fragment. Use the immediate
// method to avoid the editor picking up the new tunnel while it is still visible.
fragmentManager.popBackStackImmediate();
} else if (backStackEntries == 0) {
// Create and show a new detail fragment.
fragmentManager.beginTransaction()
.add(R.id.detail_container, new TunnelDetailFragment())
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.addToBackStack(null)
.commit();
}
}
}
代码示例来源:origin: pranavpandey/dynamic-support
@Override
public void onBackStackChanged() {
final int fragmentsCount =
getSupportFragmentManager().getBackStackEntryCount();
if (fragmentsCount > 0) {
mContentFragmentTag = getSupportFragmentManager()
.getBackStackEntryAt(fragmentsCount - 1).getName();
if (mContentFragmentTag != null) {
mContentFragment = getSupportFragmentManager()
.findFragmentByTag(mContentFragmentTag);
}
} else {
mContentFragment = getSupportFragmentManager()
.findFragmentById(R.id.ads_container);
}
}
});
代码示例来源:origin: gateship-one/odyssey
if (fragmentManager.getBackStackEntryCount() == 0) {
} else if (fragmentManager.getBackStackEntryCount() > 0) {
onBackPressed();
} else {
代码示例来源:origin: gateship-one/odyssey
if (fragmentManager.getBackStackEntryCount() == 0) {
if (fragmentManager.getBackStackEntryCount() == 0) {
mDrawerToggle.setDrawerIndicatorEnabled(true);
内容来源于网络,如有侵权,请联系作者删除!