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

fragmentManager.findFragmentByTag sometime cannot find an attaching BindingFragment #8

Open
microstudent opened this issue Sep 6, 2018 · 0 comments

Comments

@microstudent
Copy link

microstudent commented Sep 6, 2018

when binding on Activity/Fragment onCreate() , Rxlifecycle would add an bindingFragment, look like this:

protected void onCreate(Bundle savedInstanceState) {
    	Log.d(TAG, "" + "ActionBarActivity onCreate");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jnitest);
 
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment(), "myfragment")
                    .commit();
        }
        Log.d(TAG, "Fragment:"+getSupportFragmentManager().findFragmentById(R.id.container));

findFragmentById will return null.
if we bind lifeCycle during onCreate() more than once, which is very common to do such as load a lot of data, it would attach more than one BindingFragment !
and it seems to be wrong.

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

1 participant