本文整理汇总了Java中android.support.v4.app.Fragment.isRemoving方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.isRemoving方法的具体用法?Java Fragment.isRemoving怎么用?Java Fragment.isRemoving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.isRemoving方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retainPresenterInstance
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private boolean retainPresenterInstance(boolean keepPresenterOnBackstack, Activity activity,
Fragment fragment) {
if (activity.isChangingConfigurations()) {
if (keepPresenterDuringScreenOrientationChange) {
return true;
}
return false;
}
if (activity.isFinishing()) {
return false;
}
if (keepPresenterOnBackstack && BackstackAccessor.isFragmentOnBackStack(fragment)) {
return true;
}
return !fragment.isRemoving();
}
示例2: onDestroy
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}
boolean anyParentIsRemoving = false;
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}
if (isRemoving() || anyParentIsRemoving || getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
if (presenterCallback != null) {
presenterCallback.onDestroyPresenter();
}
}
}
示例3: getFragments
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public List<Fragment> getFragments() {
List<Fragment> result = new ArrayList<>();
int index = 0;
while (true) {
String tag = getFragmentTag(index);
Fragment fragment = mFragmentManager.findFragmentByTag(tag);
if (fragment == null) {
break;
}
if (!fragment.isRemoving()) {
result.add(fragment);
}
index++;
}
return result;
}
示例4: onDestroy
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}
// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}
// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}
if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}
示例5: onDestroy
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
//We leave the screen and respectively all fragments will be destroyed
if (getActivity().isFinishing()) {
getMvpDelegate().onDestroy();
return;
}
// When we rotate device isRemoving() return true for fragment placed in backstack
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving
if (mIsStateSaved) {
mIsStateSaved = false;
return;
}
// See https://github.com/Arello-Mobile/Moxy/issues/24
boolean anyParentIsRemoving = false;
if (Build.VERSION.SDK_INT >= 17) {
Fragment parent = getParentFragment();
while (!anyParentIsRemoving && parent != null) {
anyParentIsRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}
}
if (isRemoving() || anyParentIsRemoving) {
getMvpDelegate().onDestroy();
}
}
示例6: isAnyParentOfFragmentRemoving
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private boolean isAnyParentOfFragmentRemoving() {
boolean isAnyParentRemoving = false;
Fragment parent = fragment.getParentFragment();
while (!isAnyParentRemoving && parent != null) {
isAnyParentRemoving = parent.isRemoving();
parent = parent.getParentFragment();
}
return isAnyParentRemoving;
}
示例7: operateFragment
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* 操作fragment
*
* @param fragmentManager fragment管理器
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @param type 操作类型
* @param sharedElements 共享元素
* @return destFragment
*/
private static Fragment operateFragment(@NonNull final FragmentManager fragmentManager,
final Fragment srcFragment,
@NonNull Fragment destFragment,
final int type,
final SharedElement... sharedElements) {
if (srcFragment == destFragment) return null;
if (srcFragment != null && srcFragment.isRemoving()) {
Log.e("FragmentUtils", srcFragment.getClass().getName() + " is isRemoving");
return null;
}
String name = destFragment.getClass().getName();
Bundle args = destFragment.getArguments();
FragmentTransaction ft = fragmentManager.beginTransaction();
if (sharedElements == null || sharedElements.length == 0) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
} else {
for (SharedElement element : sharedElements) {// 添加共享元素动画
ft.addSharedElement(element.sharedElement, element.name);
}
}
switch (type) {
case TYPE_ADD_HIDE_FRAGMENT:
ft.hide(srcFragment);
case TYPE_ADD_FRAGMENT:
Fragment fragmentByTag = fragmentManager.findFragmentByTag(name);
if (fragmentByTag != null) {
if (fragmentByTag.isAdded()) {
ft.remove(fragmentByTag);
}
}
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(destFragment);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_REMOVE_FRAGMENT:
ft.remove(destFragment);
break;
case TYPE_REMOVE_TO_FRAGMENT:
List<Fragment> fragments = getFragments(fragmentManager);
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment == destFragment) {
if (srcFragment != null) ft.remove(fragment);
break;
}
ft.remove(fragment);
}
break;
case TYPE_REPLACE_FRAGMENT:
ft.replace(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_ADD_POP_FRAGMENT:
popFragment(fragmentManager);
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_HIDE_FRAGMENT:
ft.hide(destFragment);
break;
case TYPE_SHOW_FRAGMENT:
ft.show(destFragment);
break;
case TYPE_SHOW_HIDE_FRAGMENT:
ft.hide(srcFragment).show(destFragment);
break;
}
ft.commitAllowingStateLoss();
return destFragment;
}
示例8: operateFragment
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* 操作fragment
*
* @param fragmentManager fragment管理器
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @param type 操作类型
* @param sharedElements 共享元素
* @return destFragment
*/
private static Fragment operateFragment(@NonNull FragmentManager fragmentManager,
Fragment srcFragment,
@NonNull Fragment destFragment,
int type,
SharedElement... sharedElements) {
if (srcFragment == destFragment) return null;
if (srcFragment != null && srcFragment.isRemoving()) {
LogUtils.e(srcFragment.getClass().getName() + " is isRemoving");
return null;
}
String name = destFragment.getClass().getName();
Bundle args = destFragment.getArguments();
FragmentTransaction ft = fragmentManager.beginTransaction();
if (sharedElements == null || sharedElements.length == 0) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
} else {
for (SharedElement element : sharedElements) {// 添加共享元素动画
ft.addSharedElement(element.sharedElement, element.name);
}
}
switch (type) {
case TYPE_ADD_FRAGMENT:
if (srcFragment != null) ft.hide(srcFragment);
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(destFragment);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_REMOVE_FRAGMENT:
ft.remove(destFragment);
break;
case TYPE_REMOVE_TO_FRAGMENT:
List<Fragment> fragments = getFragments(fragmentManager);
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment == destFragment) {
if (srcFragment != null) ft.remove(fragment);
break;
}
ft.remove(fragment);
}
break;
case TYPE_REPLACE_FRAGMENT:
ft.replace(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_POP_ADD_FRAGMENT:
popFragment(fragmentManager);
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_HIDE_FRAGMENT:
ft.hide(destFragment);
break;
case TYPE_SHOW_FRAGMENT:
ft.show(destFragment);
break;
case TYPE_HIDE_SHOW_FRAGMENT:
ft.hide(srcFragment).show(destFragment);
break;
}
ft.commitAllowingStateLoss();
return destFragment;
}
示例9: operateFragment
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* 操作fragment
*
* @param fragmentManager fragment管理器
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @param type 操作类型
* @param sharedElements 共享元素
* @return destFragment
*/
private static Fragment operateFragment(@NonNull FragmentManager fragmentManager,
Fragment srcFragment,
@NonNull Fragment destFragment,
int type,
SharedElement... sharedElements) {
if (srcFragment == destFragment) return null;
if (srcFragment != null && srcFragment.isRemoving()) {
LogUtils.e(srcFragment.getClass().getName() + " is isRemoving");
return null;
}
String name = destFragment.getClass().getName();
Bundle args = destFragment.getArguments();
FragmentTransaction ft = fragmentManager.beginTransaction();
if (sharedElements == null || sharedElements.length == 0) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
} else {
for (SharedElement element : sharedElements) {// 添加共享元素动画
ft.addSharedElement(element.sharedElement, element.name);
}
}
switch (type) {
case TYPE_HIDE_ADD_FRAGMENT:
ft.hide(srcFragment);
case TYPE_ADD_FRAGMENT:
Fragment fragmentByTag = fragmentManager.findFragmentByTag(name);
if (fragmentByTag != null) {
destFragment = fragmentByTag;
} else {
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(destFragment);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
}
break;
case TYPE_REMOVE_FRAGMENT:
ft.remove(destFragment);
break;
case TYPE_REMOVE_TO_FRAGMENT:
List<Fragment> fragments = getFragments(fragmentManager);
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment == destFragment) {
if (srcFragment != null) ft.remove(fragment);
break;
}
ft.remove(fragment);
}
break;
case TYPE_REPLACE_FRAGMENT:
ft.replace(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_POP_ADD_FRAGMENT:
popFragment(fragmentManager);
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_HIDE_FRAGMENT:
ft.hide(destFragment);
break;
case TYPE_SHOW_FRAGMENT:
ft.show(destFragment);
break;
case TYPE_HIDE_SHOW_FRAGMENT:
ft.hide(srcFragment).show(destFragment);
break;
}
ft.commitAllowingStateLoss();
return destFragment;
}
示例10: operateFragment
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* 操作fragment
*
* @param fragmentManager fragment管理器
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @param type 操作类型
* @param sharedElements 共享元素
* @return destFragment
*/
private static Fragment operateFragment(@NonNull FragmentManager fragmentManager,
Fragment srcFragment,
@NonNull Fragment destFragment,
int type,
SharedElement... sharedElements) {
if (srcFragment == destFragment) return null;
if (srcFragment != null && srcFragment.isRemoving()) {
return null;
}
String name = destFragment.getClass().getName();
Bundle args = destFragment.getArguments();
FragmentTransaction ft = fragmentManager.beginTransaction();
if (sharedElements == null || sharedElements.length == 0) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
} else {
for (SharedElement element : sharedElements) {// 添加共享元素动画
ft.addSharedElement(element.sharedElement, element.name);
}
}
switch (type) {
case TYPE_ADD_FRAGMENT:
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(destFragment);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_REMOVE_FRAGMENT:
ft.remove(destFragment);
break;
case TYPE_REMOVE_TO_FRAGMENT:
List<Fragment> fragments = getFragments(fragmentManager);
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment == destFragment) {
if (srcFragment != null) ft.remove(fragment);
break;
}
ft.remove(fragment);
}
break;
case TYPE_REPLACE_FRAGMENT:
ft.replace(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_POP_ADD_FRAGMENT:
popFragment(fragmentManager);
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_HIDE_FRAGMENT:
ft.hide(destFragment);
break;
case TYPE_SHOW_FRAGMENT:
ft.show(destFragment);
break;
case TYPE_HIDE_SHOW_FRAGMENT:
ft.hide(srcFragment).show(destFragment);
break;
}
ft.commitAllowingStateLoss();
return destFragment;
}
示例11: operateFragment
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
* 操作fragment
*
* @param fragmentManager fragment管理器
* @param srcFragment 源fragment
* @param destFragment 目标fragment
* @param type 操作类型
* @param sharedElements 共享元素
* @return destFragment
*/
private static Fragment operateFragment(@NonNull final FragmentManager fragmentManager,
final Fragment srcFragment,
@NonNull Fragment destFragment,
final int type,
final SharedElement... sharedElements) {
if (srcFragment == destFragment) return null;
if (srcFragment != null && srcFragment.isRemoving()) {
LogUtils.e(srcFragment.getClass().getName() + " is isRemoving");
return null;
}
String name = destFragment.getClass().getName();
Bundle args = destFragment.getArguments();
FragmentTransaction ft = fragmentManager.beginTransaction();
if (sharedElements == null || sharedElements.length == 0) {
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
} else {
for (SharedElement element : sharedElements) {// 添加共享元素动画
ft.addSharedElement(element.sharedElement, element.name);
}
}
switch (type) {
case TYPE_HIDE_ADD_FRAGMENT:
ft.hide(srcFragment);
case TYPE_ADD_FRAGMENT:
Fragment fragmentByTag = fragmentManager.findFragmentByTag(name);
if (fragmentByTag != null) {
destFragment = fragmentByTag;
}
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_HIDE)) ft.hide(destFragment);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_REMOVE_FRAGMENT:
ft.remove(destFragment);
break;
case TYPE_REMOVE_TO_FRAGMENT:
List<Fragment> fragments = getFragments(fragmentManager);
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment == destFragment) {
if (srcFragment != null) ft.remove(fragment);
break;
}
ft.remove(fragment);
}
break;
case TYPE_REPLACE_FRAGMENT:
ft.replace(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_POP_ADD_FRAGMENT:
popFragment(fragmentManager);
ft.add(args.getInt(ARGS_ID), destFragment, name);
if (args.getBoolean(ARGS_IS_ADD_STACK)) ft.addToBackStack(name);
break;
case TYPE_HIDE_FRAGMENT:
ft.hide(destFragment);
break;
case TYPE_SHOW_FRAGMENT:
ft.show(destFragment);
break;
case TYPE_HIDE_SHOW_FRAGMENT:
ft.hide(srcFragment).show(destFragment);
break;
}
ft.commitAllowingStateLoss();
return destFragment;
}