You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static boolean USE_PREDICTIVE_BACK = true;
/**
* Control whether FragmentManager uses the new state predictive back feature that allows
* seeing the previous Fragment when using gesture back.
* <p>
* This should only be changed <strong>before</strong> any fragment transactions are done
* (i.e., in your <code>Application</code> class or prior to <code>super.onCreate()</code>
* in every activity).
*
* @param enabled Whether predictive back should be enabled.
*/
@PredictiveBackControl
public static void enablePredictiveBack(boolean enabled) {
FragmentManager.USE_PREDICTIVE_BACK = enabled;
}
This sets a new behavior for ALL fragment managers in the entire app.
However, the problem is that the way this is handled in the FragmentManager via an internal fragment operation and an internal back callback handler, which means it's completely inaccessible from outside. The idea is that it "reverts" the "current fragment transaction on the fragment backstack" as you are dragging the gesture, reversing any SpecialEffectsControllers that are attributed to a Fragment.
However, DefaultFragmentStateChanger doesn't use .addToBackStack(). This means that in order to be able to use FragmentManager.USE_PREDICTIVE_BACK, you ***have to use .addToBackStack(), which however does not support "any arbitrary operations to navigate between various fragments", somehow we need to track the transactions with which a given fragment was added, revert up to that point, and add new fragments after.
This is quite a pain. Not using .addToBackStack() is a very powerful feature as it removed many limitations. However, a new FragmentStateChanger might need to be created in order to handle the new touch gesture in-app back handling paradigm, and regain feature parity against Navigation again.
The text was updated successfully, but these errors were encountered:
Funnily enough, if you use .add() + setMaxLifecycle(RESUMED) (unfortunately it cannot be stopped as that destroys the views 😒 ), you could theoretically just translate the fragment to the side and you'd see the views underneath
This sets a new behavior for ALL fragment managers in the entire app.
However, the problem is that the way this is handled in the FragmentManager via an internal fragment operation and an internal back callback handler, which means it's completely inaccessible from outside. The idea is that it "reverts" the "current fragment transaction on the fragment backstack" as you are dragging the gesture, reversing any SpecialEffectsControllers that are attributed to a Fragment.
However,
DefaultFragmentStateChanger
doesn't use.addToBackStack()
. This means that in order to be able to useFragmentManager.USE_PREDICTIVE_BACK
, you ***have to use.addToBackStack()
, which however does not support "any arbitrary operations to navigate between various fragments", somehow we need to track the transactions with which a given fragment was added, revert up to that point, and add new fragments after.This is quite a pain. Not using
.addToBackStack()
is a very powerful feature as it removed many limitations. However, a new FragmentStateChanger might need to be created in order to handle the new touch gesture in-app back handling paradigm, and regain feature parity against Navigation again.The text was updated successfully, but these errors were encountered: