void ClearTopFragments(Fragment moveToTopFragment) { for (int i = fragmentStack.Count - 1; i >= 0; i--) { Fragment fragment = fragmentStack[i]; if (!fragment.Equals(moveToTopFragment)) { fragmentStack.RemoveAt(i); fragment.OnExitStack(); } else { break; } } }
void FragmentExitStack(Fragment deleteFragment, bool isCallBack = true) { //从后面删 避免存在相同引用的fragment删除了前面的 for (int i = fragmentStack.Count - 1; i >= 0; i--) { Fragment fragment = fragmentStack[i]; if (fragment.Equals(deleteFragment)) { fragmentStack.RemoveAt(i); if (isCallBack) { fragment.OnExitStack(); } break; } } }