Is this a bad coding style?
IMHO, yes. IMHO, the fragment should not know and do not care about other fragments controlled by this activity. A fragment can take care of nested fragments (child fragments via getChildFragmentManager() ), but not possible fragment fragments.
In the case of the above example, TitlesFragment does not care if it is displayed in single or dual panel mode. Activities should take care of this. This isolates all screen size-dependent code in activity - TitlesFragment may not pay attention to screen size.
As they say, with the AFAIK code, there is nothing technically wrong - this is not the way I would recommend it.
source share