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

Why do you do? #2289

Closed
adwilme110 opened this issue Aug 25, 2017 · 1 comment
Closed

Why do you do? #2289

adwilme110 opened this issue Aug 25, 2017 · 1 comment
Labels

Comments

@adwilme110
Copy link

SupportRequestManagerFragment getSupportRequestManagerFragment(
final FragmentManager fm, Fragment parentHint) {
SupportRequestManagerFragment current =
(SupportRequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG);
if (current == null) {
current = pendingSupportRequestManagerFragments.get(fm);
if (current == null) {
current = new SupportRequestManagerFragment();
current.setParentFragmentHint(parentHint);
pendingSupportRequestManagerFragments.put(fm, current);
fm.beginTransaction().add(current, FRAGMENT_TAG).commitAllowingStateLoss();
handler.obtainMessage(ID_REMOVE_SUPPORT_FRAGMENT_MANAGER, fm).sendToTarget();
}
}
return current;
}

first,you add current,then you move it?

@sjudd sjudd added the question label Aug 28, 2017
@sjudd
Copy link
Collaborator

sjudd commented Aug 28, 2017

Are you referring to this line?:

RequestManagerFragment current = (RequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG);

If so, ID_REMOVE_SUPPORt_FRAGMENT_MANAGER is used to remove the Fragment from pendingSupportRequestManagerFragments only, it doesn't not remove the Fragment from the FragmentManager:

handler.obtainMessage(ID_REMOVE_FRAGMENT_MANAGER, fm).sendToTarget();
.

This logic is necessary because we cannot use commitNow() or executePendingTransactions() because doing so causes recursive Fragment changes in some circumstances. Adding the Fragment to a temporary set allows us to avoid adding multiple Fragments if multiple loads are started during the brief period between when we first commit the FragmentTransaction and when the transaction actually runs.

@sjudd sjudd closed this as completed Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants