I have an Activity that uses a single custom DialogFragment class. Its appearance is data driven, so it can look fairly different from invocation to invocation.
It is "full screen", i.e.
setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme);
In response to the result of a network call I dismiss() the currently showing instance (if there is one) and show() a new one:
final CustomDialogFragment dialog = (CustomDialogFragment) getSupportFragmentManager().findFragmentByTag(DIALOG_TAG_CUSTOM);
if (dialog != null)
dialog.dismiss();
final CustomDialogFragment newdialog = new CustomDialogFragment();
// configure some stuff on the new fragment that influences its appearance
newdialog.show();
Here is my issue: when this block of code runs, between the point at which the existing Fragment disappears and the new one becomes visible I can briefly see the underlying Activity. I'd like to avoid this somehow.
My first thought was to dismiss the existing fragment inside the onResume() method of the new fragment. That is, to delay the "dismiss()" call as long as possible in hopes that the new fragment would already be visible (obscuring the previous one) before the previous one was dismissed. But this had no effect.
Another option I'm considering is to make the fragment "reconfigurable" so that I can "push in" new data and trigger it to redraw all its views to match the new data. In this solution, I would simply reconfigure the existing fragment (if there is one) instead of dismissing it and showing a new one.
My question: is there an easier and/or more straightforward way to get around this temporary "peek" at the underlying Activity when dismissing one full-screen DialogFragment and showing another?