[FragmentStrictMode] Detect <fragment> tag usage#141
[FragmentStrictMode] Detect <fragment> tag usage#141simonschiller wants to merge 1 commit intoandroidx:androidx-mainfrom
Conversation
| + "re-attached via the <fragment> tag: id=0x" + Integer.toHexString(id)); | ||
| } | ||
| } | ||
| FragmentStrictMode.onFragmentTagUsage(fragment); |
There was a problem hiding this comment.
I think we should make the call on line 74 before we check the ID and tag. The idea being that if you are using strict mode, we should throw this before we even check if you are using tag correctly.
There was a problem hiding this comment.
I wanted to do that originally, but the problem there is that we don't have a Fragment instance yet. If there is a reliable way to traverse up the FragmentManager hierarchy without a concrete Fragment instance, that would also work, but I couldn't find one. We need the traversal to figure out the correct policy.
There was a problem hiding this comment.
There is a package private findFragmentManager that finds the FragmentManager associated with a given view, but I don't think that helps here much.
d621dcc to
4ea0525
Compare
Proposed Changes
<fragment>tag usage inside XML layoutsTesting
Test: See
FragmentStrictModeTest#detectFragmentTagUsageIssues Fixed
Fixes: 153738235