1

I'm trying to open a DialogFragment in a Presentation view.

But the DialogFragment keeps showing up in the Activity where the Presentation is projected from.

Can we have the DialogFragment in the Presentation itself or is this impossible since Presentation is extended from Dialog?

private void showMobileNumberEntryDialog() {
        mobileNumberViewModel.setMobileNumberDialogVisibility(true);
        FragmentTransaction ft = ((AppCompatActivity) referenceActivity).getSupportFragmentManager()
                .beginTransaction();
        if (customerNumberInputDialogVisible) {
            Fragment oldFragment = ((AppCompatActivity) referenceActivity).getSupportFragmentManager()
                    .findFragmentByTag("fragment_mobile_number_input");
            if (oldFragment != null) {
                ft.remove(oldFragment);
            }
            MobileNumberInputFragment mobileNumberInputFragment = MobileNumberInputFragment.newInstance(customerNumberInputViewMode);
            mobileNumberInputFragment.show(ft, "fragment_mobile_number_input");
        } else {
            Fragment oldFragment = ((AppCompatActivity) referenceActivity).
                    getSupportFragmentManager().findFragmentByTag("fragment_mobile_number_input");
            if (oldFragment != null) {
                ft.remove(oldFragment);
                ft.commit();
            }
        }
}

The referenceActivity here is from the source activity where the Presentation is being projected from.

Nimila Hiranya
  • 4,842
  • 10
  • 35
  • 52
  • 1
    "Can we have the DialogFragment in the Presentation itself" -- I suspect not. "is this impossible since Presentation is extended from Dialog?" -- I think that is indeed your problem. However, you could hide/show some UI in the `Presentation` that just happens to resemble a dialog. – CommonsWare Feb 16 '23 at 22:19
  • @CommonsWare yeah, that was my fallback. Anyways, thank you. – Nimila Hiranya Feb 17 '23 at 00:00

0 Answers0