Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

popTo() has not been attached yet #1265

Closed
luziqi123 opened this issue Jun 3, 2021 · 2 comments
Closed

popTo() has not been attached yet #1265

luziqi123 opened this issue Jun 3, 2021 · 2 comments

Comments

@luziqi123
Copy link

luziqi123 commented Jun 3, 2021

在使用最新版的时候调用popTo()方法报出了 has not been attached yet 错误。
一点一点debug发现在onHiddenChanged的时候调用了一个 onFragmentShownWhenNotResumed() 方法。在这个方法调用了mFragment.getChildFragmentManager(); 然而在之前的一大堆方法调用中已经触发Fragment的mHose = null的操作了,所以就报错了。。
�我目前的解决办法是在前面做一个判断,现在我的VisibleDelegate.java下dispatchChildOnFragmentShownWhenNotResumed方法长这样儿:

    private void dispatchChildOnFragmentShownWhenNotResumed() {
        if (!mFragment.isAdded()) {
            return;
        }
        FragmentManager fragmentManager = mFragment.getChildFragmentManager();
        List<Fragment> childFragments = fragmentManager.getFragments();
        if (childFragments != null) {
            for (Fragment child : childFragments) {
                if (child instanceof ISupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
                    ((ISupportFragment) child).getSupportDelegate().getVisibleDelegate().onFragmentShownWhenNotResumed();
                }
            }
        }
    }
@chenyao1208
Copy link

请问大佬上述代码要加在哪个地方,我全局搜索没有找到VisibleDelegate相关的类啊,望指点

@n272367953
Copy link

n272367953 commented Aug 23, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants