Open DialogFragment from Presentation in Android

43 views Asked by At

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.

0

There are 0 answers