Java Code Examples for android.support.v4.app.fragment#isResumed()
The following examples show how to use
android.support.v4.app.fragment#isResumed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentUtils.java From styT with Apache License 2.0 | 6 votes |
/** * 根据栈参数获取顶层可见fragment * * @param fragmentManager fragment管理器 * @param parentFragment 父fragment * @param isInStack 是否是栈中的 * @return 栈中顶层可见fragment */ private static Fragment getTopShowFragmentIsInStack(@NonNull final FragmentManager fragmentManager, final Fragment parentFragment, final boolean isInStack) { List<Fragment> fragments = getFragments(fragmentManager); if (fragments.isEmpty()) return parentFragment; for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) { if (isInStack) { if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true); } } else { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false); } } } return parentFragment; }
Example 2
Source File: FragmentUtils.java From styT with Apache License 2.0 | 6 votes |
/** * 处理fragment回退键 * <p>如果fragment实现了OnBackClickListener接口,返回{@code true}: 表示已消费回退键事件,反之则没消费</p> * <p>具体示例见FragmentActivity</p> * * @param fragmentManager fragment管理器 * @return 是否消费回退事件 */ public static boolean dispatchBackPress(@NonNull final FragmentManager fragmentManager) { List<Fragment> fragments = fragmentManager.getFragments(); if (fragments == null || fragments.isEmpty()) return false; for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint() && fragment instanceof OnBackClickListener && ((OnBackClickListener) fragment).onBackClick()) { return true; } } return false; }
Example 3
Source File: FragmentUtils.java From TikTok with Apache License 2.0 | 6 votes |
/** * 根据栈参数获取顶层可见fragment * * @param fragmentManager fragment管理器 * @param parentFragment 父fragment * @param isInStack 是否是栈中的 * @return 栈中顶层可见fragment */ private static Fragment getTopShowFragmentIsInStack(@NonNull FragmentManager fragmentManager, Fragment parentFragment, boolean isInStack) { List<Fragment> fragments = getFragments(fragmentManager); if (fragments.isEmpty()) return parentFragment; for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) { if (isInStack) { if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true); } } else { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false); } } } return parentFragment; }
Example 4
Source File: FragmentUtils.java From TikTok with Apache License 2.0 | 6 votes |
/** * 处理fragment回退键 * <p>如果fragment实现了OnBackClickListener接口,返回{@code true}: 表示已消费回退键事件,反之则没消费</p> * <p>具体示例见FragmentActivity</p> * * @param fragmentManager fragment管理器 * @return 是否消费回退事件 */ public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) { List<Fragment> fragments = fragmentManager.getFragments(); if (fragments == null || fragments.isEmpty()) return false; for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint() && fragment instanceof OnBackClickListener && ((OnBackClickListener) fragment).onBackClick()) { return true; } } return false; }
Example 5
Source File: FragmentUtils.java From Android-UtilCode with Apache License 2.0 | 6 votes |
/** * 根据栈参数获取顶层可见fragment * * @param fragmentManager fragment管理器 * @param parentFragment 父fragment * @param isInStack 是否是栈中的 * @return 栈中顶层可见fragment */ private static Fragment getTopShowFragmentIsInStack(@NonNull FragmentManager fragmentManager, Fragment parentFragment, boolean isInStack) { List<Fragment> fragments = getFragments(fragmentManager); if (fragments.isEmpty()) return parentFragment; for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) { if (isInStack) { if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true); } } else { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false); } } } return parentFragment; }
Example 6
Source File: FragmentUtils.java From Android-UtilCode with Apache License 2.0 | 6 votes |
/** * 处理fragment回退键 * <p>如果fragment实现了OnBackClickListener接口,返回{@code true}: 表示已消费回退键事件,反之则没消费</p> * <p>具体示例见FragmentActivity</p> * * @param fragmentManager fragment管理器 * @return 是否消费回退事件 */ public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) { List<Fragment> fragments = fragmentManager.getFragments(); if (fragments == null || fragments.isEmpty()) return false; for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint() && fragment instanceof OnBackClickListener && ((OnBackClickListener) fragment).onBackClick()) { return true; } } return false; }
Example 7
Source File: FragmentUtils.java From MVVMArms with Apache License 2.0 | 6 votes |
/** * 根据栈参数获取顶层可见fragment * * @param fragmentManager fragment管理器 * @param parentFragment 父fragment * @param isInStack 是否是栈中的 * @return 栈中顶层可见fragment */ private static Fragment getTopShowFragmentIsInStack(@NonNull FragmentManager fragmentManager, Fragment parentFragment, boolean isInStack) { List<Fragment> fragments = getFragments(fragmentManager); if (fragments.isEmpty()) { return parentFragment; } for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) { if (isInStack) { if (fragment.getArguments().getBoolean(ARGS_IS_ADD_STACK)) { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, true); } } else { return getTopShowFragmentIsInStack(fragment.getChildFragmentManager(), fragment, false); } } } return parentFragment; }
Example 8
Source File: FragmentUtils.java From MVVMArms with Apache License 2.0 | 6 votes |
/** * 处理fragment回退键 * <p>如果fragment实现了OnBackClickListener接口,返回{@code true}: 表示已消费回退键事件,反之则没消费</p> * <p>具体示例见FragmentActivity</p> * * @param fragmentManager fragment管理器 * @return 是否消费回退事件 */ public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) { List<Fragment> fragments = fragmentManager.getFragments(); if (fragments == null || fragments.isEmpty()) { return false; } for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint() && fragment instanceof OnBackClickListener && ((OnBackClickListener) fragment).onBackClick()) { return true; } } return false; }
Example 9
Source File: FragmentUtils.java From AndroidUtilCode with Apache License 2.0 | 6 votes |
private static Fragment getTopShowIsInStack(@NonNull final FragmentManager fm, Fragment parentFragment, final boolean isInStack) { List<Fragment> fragments = getFragments(fm); for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint()) { if (isInStack) { Bundle args = fragment.getArguments(); if (args != null && args.getBoolean(ARGS_IS_ADD_STACK)) { return getTopShowIsInStack(fragment.getChildFragmentManager(), fragment, true); } } else { return getTopShowIsInStack(fragment.getChildFragmentManager(), fragment, false); } } } return parentFragment; }
Example 10
Source File: FragmentUtils.java From AndroidUtilCode with Apache License 2.0 | 6 votes |
/** * Dispatch the back press for fragment. * * @param fm The manager of fragment. * @return {@code true}: the fragment consumes the back press<br>{@code false}: otherwise */ public static boolean dispatchBackPress(@NonNull final FragmentManager fm) { List<Fragment> fragments = getFragments(fm); if (fragments == null || fragments.isEmpty()) return false; for (int i = fragments.size() - 1; i >= 0; --i) { Fragment fragment = fragments.get(i); if (fragment != null && fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint() && fragment instanceof OnBackClickListener && ((OnBackClickListener) fragment).onBackClick()) { return true; } } return false; }
Example 11
Source File: Monitor.java From BehaviorCollect with GNU General Public License v3.0 | 5 votes |
public void onFragmentHiddenChanged(Fragment fragment, boolean hidden) { if (!collectMode) return; //非收集模式 退出 if (!fragment.isResumed()) return; //未初始化 退出 if (hidden) { onFragmentPageEnd(fragment); } else { onFragmentPageStart(fragment); } }
Example 12
Source File: Monitor.java From BehaviorCollect with GNU General Public License v3.0 | 5 votes |
public void setUserVisibleHint(Fragment fragment, boolean isVisibleToUser) { if (!collectMode) return; //非收集模式 退出 if (!fragment.isResumed()) return; //未初始化 退出 if (isVisibleToUser) { onFragmentPageStart(fragment); } else { onFragmentPageEnd(fragment); } }
Example 13
Source File: FragmentUtils.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
/** * Dispatch the back press for fragment. * * @param fragment The fragment. * @return {@code true}: the fragment consumes the back press<br>{@code false}: otherwise */ public static boolean dispatchBackPress(@NonNull final Fragment fragment) { return fragment.isResumed() && fragment.isVisible() && fragment.getUserVisibleHint() && fragment instanceof OnBackClickListener && ((OnBackClickListener) fragment).onBackClick(); }
Example 14
Source File: FragmentResumedInstruction.java From YaMvp with MIT License | 5 votes |
@Override public boolean checkCondition() { AppCompatActivity activity = (AppCompatActivity) ((TestApplication) InstrumentationRegistry.getTargetContext() .getApplicationContext()).getCurrentActivity(); Fragment fragment = activity.getSupportFragmentManager().findFragmentById(android.R.id.content); return fragment.isResumed(); }