Issue
I have a navigation graph that looks like this:
Fragment 1 --> (Action A) --> DialogFragment 1 --> (Action B) --> Fragment 2
When performing Action B, we unfortunately don't switch directly directly to Fragment 2. Instead, the screen first shows Fragment 1 for a short moment (0.1 seconds or so), which looks very bad for my flow.
I'm using the feature as suggested in this answer, with navigation-fragment version 2.1.0-rc01, which is the most stable version currently available with the <dialog>
feature.
Solution
TL;DR: Override the dismiss()
function of your DialogFragment
:
public class MyDialogFragment extends DialogFragment {
...
@Override
public void dismiss() {
getFragmentManager().executePendingTransactions();
getView().post(() -> super.dismiss());
}
}
This is just a patch until the feature will be fixed, it works for me, please update especially if it doesn't work for you.
The problem is some race between:
- The fragment transaction to Fragment 2 (which is correctly called first in
Navigation.java
, seeNavDestination newDest = navigator.navigate(...
, but probably takes a moment in the looper queue before being executed )
And
- The Dialog
dismiss()
(which is correctly called only afterwards, but happens first)
Answered By - Hibuki
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.