79596431

Date: 2025-04-28 12:06:59
Score: 0.5
Natty:
Report link

Calling getChildFragmentManager() in the parent fragment thus making the created dialog a child of the parent fragment has a very good reason when the parent fragment needs to share its viewModel with its child dialog.

Better to describe it by a use-case. Let's say the parent fragment shows a list of data that can be sorted using various ways and the user can open a (child) dialog where it can set the sorting details of the list. The child dialog allows the user to change the sorting and the easiest way is to share a single viewModel between both - the parent fragment and the child dialog. Once the user changes the viewModel and closes the dialog, the parent fragment refreshes using the newly provided sorting details.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: pepan