本文整理汇总了Java中android.support.v4.app.FragmentManager.popBackStackImmediate方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.popBackStackImmediate方法的具体用法?Java FragmentManager.popBackStackImmediate怎么用?Java FragmentManager.popBackStackImmediate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.popBackStackImmediate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: popMultipleBackStack
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 一次弹出多个Fragment
*
* @param tag
* @param popFlag 0 弹出不包括tag所指的Fragment;1 表示弹出包括当前tag的fragment
* @param bundle 回退栈 传输参数
*/
public void popMultipleBackStack(String tag, int popFlag, Bundle bundle) {
if (bundle != null) {
setSupportBackStackArguments(bundle);
}
//维护后退栈内容,保持同步
if (mFragmentBackDeque.contains(tag)) {
String peekElement = mFragmentBackDeque.peek();
while (!tag.equals(peekElement)) {
if (mFragmentBackDeque.isEmpty()) {
break;
}
mFragmentBackDeque.pop();
peekElement = mFragmentBackDeque.peek();
}
if (popFlag == 1) {
if (!mFragmentBackDeque.isEmpty()) {
mFragmentBackDeque.pop();
}
}
}
FragmentManager manager = getSupportFragmentManager();
manager.popBackStackImmediate(tag, popFlag);
}
示例2: replaceCurrentFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void replaceCurrentFragment(int container, Fragment targetFragment,
String tag, boolean addToBackStack, boolean animate) {
if (!isFinishing()) {
FragmentManager manager = getSupportFragmentManager();
boolean fragmentPopped = manager.popBackStackImmediate(tag, 0);
if (!fragmentPopped && manager.findFragmentByTag(tag) == null) {
FragmentTransaction ft = manager.beginTransaction();
if (animate)
ft.setCustomAnimations(R.anim.slide_out_right,
R.anim.slide_in_left, R.anim.slide_out_left,
R.anim.slide_in_right);
ft.replace(container, targetFragment, tag);
if (addToBackStack) {
ft.addToBackStack(tag);
}
ft.commit();
}
}
}
示例3: popAllFragments
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 出栈所有fragment
*
* @param fragmentManager fragment管理器
*/
public static void popAllFragments(@NonNull final FragmentManager fragmentManager) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null) popAllFragments(fragment.getChildFragmentManager());
}
while (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStackImmediate();
}
}
示例4: clearBackStackFragmets
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void clearBackStackFragmets(final String tag)
{
// in my case I get the support fragment manager, it should work with the native one too
FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
// this will clear the back stack and displays no animation on the screen
fragmentManager.popBackStackImmediate(tag, FragmentManager.POP_BACK_STACK_INCLUSIVE);
// fragmentManager.popBackStackImmediate(SplashFragment.class.getCanonicalName(),FragmentManager.POP_BACK_STACK_INCLUSIVE);
// Methods.hideKeyboard();
}
示例5: onBackPressed
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
if (dispatchBackPressToCurrentFragment()) {
return;
}
final FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager.getBackStackEntryCount() > 0 && fragmentManager.popBackStackImmediate()) {
return;
}
super.onBackPressed();
}
示例6: debouncePop
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void debouncePop(SupportFragment from, FragmentManager fragmentManager) {
// Debounce
if (from == null) {
from = getTopFragment(fragmentManager);
}
long now = System.currentTimeMillis();
if (now < mShareElementDebounceTime) return;
mShareElementDebounceTime = System.currentTimeMillis() + from.getExitAnimDuration();
fragmentManager.popBackStackImmediate();
}
示例7: navigateBack
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void navigateBack() {
activity.hideKeyboard();
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (fragmentManager.getBackStackEntryCount() > 0) {
Log.i(TAG, "Popping back stack");
int fragmentPosition = fragmentManager.getBackStackEntryCount() - 1;
FragmentManager.BackStackEntry backEntry = fragmentManager.getBackStackEntryAt(fragmentPosition);
String fragmentName = backEntry.getName();
fragmentManager.popBackStackImmediate(fragmentName, FragmentManager.POP_BACK_STACK_INCLUSIVE);
navigationManager.removeFragmentsFromStack(fragmentPosition);
} else {
Log.i(TAG, "Nothing on back stack");
if (activity.isTaskRoot()) {
if (doublePressToExit) {
activity.finish();
return;
}
doublePressToExit = true;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
doublePressToExit = false;
}
}, TIME_INTERVAL);
} else {
activity.finish();
}
}
}
示例8: popMultipleBackStack
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 一次弹出多个Fragment
*
* @param tag
* @param bundle 回退栈 传输参数
*/
private void popMultipleBackStack(String tag, Bundle bundle) {
if (bundle != null) {
setSupportBackStackArguments(bundle);
}
synchronizeFragmentBackDequeWhenSingleLaunchMode(tag);
FragmentManager manager = getSupportFragmentManager();
manager.popBackStackImmediate(tag, 0);
reorderAvailIndicesToFixBug();
}
示例9: popAllFragments
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 出栈所有fragment
*
* @param fragmentManager fragment管理器
*/
public static void popAllFragments(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty()) return;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null) popAllFragments(fragment.getChildFragmentManager());
}
while (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStackImmediate();
}
}
示例10: popAllFragments
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 出栈所有fragment
*
* @param fragmentManager fragment管理器
*/
public static void popAllFragments(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = getFragments(fragmentManager);
if (fragments.isEmpty())
return;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null)
popAllFragments(fragment.getChildFragmentManager());
}
while (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStackImmediate();
}
}
示例11: clearFragmentBackStack
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void clearFragmentBackStack() {
final FragmentManager fm = getSupportFragmentManager();
for (int i = 0; i < fm.getBackStackEntryCount(); ++i) {
fm.popBackStackImmediate();
}
}
示例12: popFragments
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* Drop the same level fragment
*
* @param fragmentManager fragment manager
*/
public static void popFragments(@NonNull FragmentManager fragmentManager) {
while (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStackImmediate();
}
}
示例13: popFragments
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 出栈同级别fragment
*
* @param fragmentManager fragment管理器
*/
public static void popFragments(@NonNull FragmentManager fragmentManager) {
while (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStackImmediate();
}
}
示例14: popToFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 出栈到指定fragment
*
* @param fragmentManager fragment管理器
* @param fragmentClass Fragment类
* @param isIncludeSelf 是否包括Fragment类自己
* @return {@code true}: 出栈成功<br>{@code false}: 出栈失败
*/
public static boolean popToFragment(@NonNull FragmentManager fragmentManager,
Class<? extends Fragment> fragmentClass,
boolean isIncludeSelf) {
return fragmentManager.popBackStackImmediate(fragmentClass.getName(), isIncludeSelf ? FragmentManager.POP_BACK_STACK_INCLUSIVE : 0);
}
示例15: popFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* 出栈fragment
*
* @param fragmentManager fragment管理器
* @return {@code true}: 出栈成功<br>{@code false}: 出栈失败
*/
public static boolean popFragment(@NonNull FragmentManager fragmentManager) {
return fragmentManager.popBackStackImmediate();
}