Disable fragment transaction animation after it is committed

I have a little unusual fragment navigation because I want the application to respond. Because of this, I use almost exclusively show / hide methods with fragments.

Whenever I want to go to another fragment and return using the return key, I add this transaction to the back. At the same time, I also configure the transition animation for this transaction, so that when the user clicks back, it shows a spread animation (effect popBackStackImmiediate ()) when the user goes to the previous fragment.

I add these animations:

fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

Lets call it A → B → A navigation. Therefore, when A moves to B, the opening animation is displayed, and then when we return to A, the turning animation is displayed.

However, the problem arises when I have a situation where I need to switch from A to B, adding this transaction to the back stack (to return to A with the Back button), and then from B to C (without adding this transaction to return stack), and from C to A when you press the back button. The problem in this scenario is that I want the user to be inadvertently transferred to fragment A when a button is pressed on this fragment C. However, since animation has been added to transaction A to B, and this transaction has been added to the back stack, when the user presses the back button on fragment C, the cancel transaction A-> B is displayed (in essence, fragment B blinks for a split second on the screen until fragment A appears).

, A- > B . , commit().

?

+4
1

, , - popBackStackImmediate() , C. , C, A.

, .

, , true, .

, , onCreateAnimation .

+1

All Articles