[FragmentStrictMode] Detect <fragment> tag usage - #141
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 - Detect `<fragment>` tag usage inside XML layouts ## Testing Test: See `FragmentStrictModeTest#detectFragmentTagUsage` ## Issues Fixed Fixes: 153738235 This is an imported pull request from androidx#141. Resolves JetBrains#141 Github-Pr-Head-Sha: 4ea0525 GitOrigin-RevId: 62e7487 Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
Proposed Changes
<fragment>tag usage inside XML layoutsTesting
Test: See
FragmentStrictModeTest#detectFragmentTagUsageIssues Fixed
Fixes: 153738235