Skip to content

Fragment has not been attached yet still happened in 1.1.6 #607

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

Closed
LichFaker opened this issue Oct 23, 2017 · 4 comments
Closed

Fragment has not been attached yet still happened in 1.1.6 #607

LichFaker opened this issue Oct 23, 2017 · 4 comments

Comments

@LichFaker
Copy link


android.support.v4.app.Fragment.instantiateChildFragmentManager(Fragment.java)

android.support.v4.app.Fragment.getChildFragmentManager(Fragment.java)
me.yokeyword.fragmentation.SupportFragment.findChildFragment(SupportFragment.java)
biz.globalvillage.newwind.ui.main.MainFragment.onLazyInitView(MainFragment.java)
 me.yokeyword.fragmentation.helper.internal.VisibleDelegate.dispatchSupportVisible(VisibleDelegate.java)
me.yokeyword.fragmentation.helper.internal.VisibleDelegate.access$000(VisibleDelegate.java)
me.yokeyword.fragmentation.helper.internal.VisibleDelegate$1.run(VisibleDelegate.java)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
 android.os.Looper.loop(Looper.java:135)
android.app.ActivityThread.main(ActivityThread.java:5290)
 java.lang.reflect.Method.invoke(Native Method)
 java.lang.reflect.Method.invoke(Method.java:372)
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
@Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        SupportFragment fragment = findChildFragment(HomeMainFragment.class);
        if (fragment == null) {
            fragments[FIRST] = HomeMainFragment.newInstance();
            fragments[SECOND] = MapMainFragment.newInstance(0);
            fragments[THIRD] = ShopFragment.newInstance("商城", Constants.H5_SHOP_LIST);
            fragments[LAST] = AccountMainFragment.newInstance();

            loadMultipleRootFragment(R.id.mainContent, 0, fragments);

        } else {
            fragments[FIRST] = fragment;
            fragments[SECOND] = findChildFragment(MapMainFragment.class);
            fragments[THIRD] = findChildFragment(ShopFragment.class);
            fragments[LAST] = findChildFragment(AccountMainFragment.class);
        }
...
}
@YoKeyword
Copy link
Owner

从Log看 MainFragment此时没有attach到宿主Activity上, 该异常发生几率如何? 可以复现吗?

代码角度上 在这里添加if (!mFragment.isAdded()) return;即可, v1.1.7将加上该安全校验

@LichFaker
Copy link
Author

该问题是线上统计发现的,有一定概率,目前数据看概率有点大的,但我本地没有复现过。
PS. 1.1.7 何时会发布?

LichFaker added a commit to LichFaker/Fragmentation that referenced this issue Oct 24, 2017
@YoKeyword
Copy link
Owner

YoKeyword commented Oct 24, 2017

已放出v1.1.7

@dx-berry
Copy link

image
v1.3.7还是会出现

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