当前位置: 首页>>代码示例>>Java>>正文


Java Fragment.getUserVisibleHint方法代码示例

本文整理汇总了Java中android.support.v4.app.Fragment.getUserVisibleHint方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.getUserVisibleHint方法的具体用法?Java Fragment.getUserVisibleHint怎么用?Java Fragment.getUserVisibleHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.Fragment的用法示例。


在下文中一共展示了Fragment.getUserVisibleHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dispatchBackPress

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 处理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;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:25,代码来源:FragmentUtils.java

示例2: getTopShowFragmentIsInStack

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 根据栈参数获取顶层可见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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:FragmentUtils.java

示例3: dispatchBackPress

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 处理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 = getFragments(fragmentManager);
    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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:FragmentUtils.java

示例4: getTopShowFragmentIsInStack

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 根据栈参数获取顶层可见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;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:28,代码来源:FragmentUtils.java

示例5: getTopShowFragmentIsInStack

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 根据栈参数获取顶层可见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;
}
 
开发者ID:yangxp108,项目名称:MVPArms_Fragment-fragment,代码行数:29,代码来源:FragmentUtils.java

示例6: dispatchBackPress

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 处理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;
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:27,代码来源:FragmentUtils.java

示例7: getTopShowFragmentIsInStack

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 根据栈参数获取顶层可见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;
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:30,代码来源:FragmentUtils.java

示例8: dispatchBackPress

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 处理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;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:25,代码来源:FragmentUtils.java

示例9: dispatchBackPress

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * Handle the fragment back key
 * <p>If fragment implements the OnBackClickListener interface, returns {@code true}: indicates that the consumer has returned the key event, otherwise it is not consumed</p>
 * <p>See FragmentActivity for specific examples</p>
 *
 * @param fragmentManager fragment manager
 * @return Whether to consume back events
 */
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;
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:26,代码来源:FragmentUtils.java

示例10: activityCreated

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public void activityCreated(){
    // 如果自己是显示状态,但父Fragment却是隐藏状态,就把自己也改为隐藏状态,并且设置一个等待显示的标记
    if(fragment.getUserVisibleHint()){
        Fragment parentFragment = fragment.getParentFragment();
        if(parentFragment != null && !parentFragment.getUserVisibleHint()){
            if(DEBUG){
                LogUtils.info(TAG, fragmentName + ": activityCreated, parent " + parentFragment.getClass().getSimpleName() + "is hidden, therefore hidden self");
            }
            userVisibleCallback.setWaitingShowToUser(true);
            userVisibleCallback.callSuperSetUserVisibleHint(false);
        }
    }
}
 
开发者ID:PlutoArchitecture,项目名称:Pluto-Android,代码行数:14,代码来源:FragmentUserVisibleController.java

示例11: compatChildFragmentExitAnim

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Nullable
public Animation compatChildFragmentExitAnim(Fragment fragment) {
    if ((fragment.getTag() != null && fragment.getTag().startsWith("android:switcher:") && fragment.getUserVisibleHint()) ||
            (fragment.getParentFragment() != null && fragment.getParentFragment().isRemoving() && !fragment.isHidden())) {
        Animation animation = new Animation() {
        };
        animation.setDuration(exitAnim.getDuration());
        return animation;
    }
    return null;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:12,代码来源:AnimatorHelper.java

示例12: dispatchSupportVisible

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void dispatchSupportVisible(boolean visible) {
    if (mIsSupportVisible == visible) {
        mNeedDispatch = true;
        return;
    }

    mIsSupportVisible = visible;

    if (!mNeedDispatch) {
        mNeedDispatch = true;
    } else {
        if (checkAddState()) return;
        FragmentManager fragmentManager = mFragment.getChildFragmentManager();
        if (fragmentManager != null) {
            List<Fragment> childFragments = FragmentationHack.getActiveFragments(fragmentManager);
            if (childFragments != null) {
                for (Fragment child : childFragments) {
                    if (child instanceof ISupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
                        ((ISupportFragment) child).getSupportDelegate().getVisibleDelegate().dispatchSupportVisible(visible);
                    }
                }
            }
        }
    }

    if (visible) {
        if (checkAddState()) return;
        mSupportF.onSupportVisible();

        if (mIsFirstVisible) {
            mIsFirstVisible = false;
            mSupportF.onLazyInitView(mSaveInstanceState);
        }
    } else {
        mSupportF.onSupportInvisible();
    }
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:38,代码来源:VisibleDelegate.java

示例13: dispatchSupportVisible

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private void dispatchSupportVisible(boolean visible) {
    mIsSupportVisible = visible;

    if (!mNeedDispatch) {
        mNeedDispatch = true;
    } else {
        FragmentManager fragmentManager = mSupportFragment.getChildFragmentManager();
        if (fragmentManager != null) {
            List<Fragment> childFragments = fragmentManager.getFragments();
            if (childFragments != null) {
                for (Fragment child : childFragments) {
                    if (child instanceof SupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
                        ((SupportFragment) child).getVisibleDelegate().dispatchSupportVisible(visible);
                    }
                }
            }
        }
    }

    if (visible) {
        mSupportFragment.onSupportVisible();

        if (mIsFirstVisible) {
            mIsFirstVisible = false;
            mSupportFragment.onLazyInitView(mSaveInstanceState);
        }
    } else {
        mSupportFragment.onSupportInvisible();
    }
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:31,代码来源:VisibleDelegate.java

示例14: getActiveFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
private static ISupportFragment getActiveFragment(FragmentManager fragmentManager, ISupportFragment parentFragment) {
    List<Fragment> fragmentList = FragmentationHack.getActiveFragments(fragmentManager);
    if (fragmentList == null) {
        return parentFragment;
    }
    for (int i = fragmentList.size() - 1; i >= 0; i--) {
        Fragment fragment = fragmentList.get(i);
        if (fragment instanceof ISupportFragment) {
            if (fragment.isResumed() && !fragment.isHidden() && fragment.getUserVisibleHint()) {
                return getActiveFragment(fragment.getChildFragmentManager(), (ISupportFragment) fragment);
            }
        }
    }
    return parentFragment;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:16,代码来源:SupportHelper.java

示例15: isFragmentBackHandled

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 判断Fragment是否处理了Back键
 * @return 如果处理了back键则返回 <b>true</b>
 */
private static boolean isFragmentBackHandled(Fragment fragment) {
    return fragment != null
            && fragment.isVisible()
            && fragment.getUserVisibleHint() //for ViewPager
            && fragment instanceof FragmentBackHandler
            && ((FragmentBackHandler) fragment).onBackPressed();
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:12,代码来源:BackHandlerHelper.java


注:本文中的android.support.v4.app.Fragment.getUserVisibleHint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。