Add logs for attempting to seek with only sharedElementTransition
If you set a sharedElementTransition for a FragmentTransaction and do
not also set a transition on the entering or exiting fragment,
DefaultSpecialEffectsController does not run any transitions.
This change is adding logs to indicate to devs exactly why the
transition is not running.
RelNote: "Added logs to indicate why setting a sharedElement without any
other transitions will fail to run."
Test: add exiting tests pass
Fixes: 300657793
(cherry picked from https://android-review.googlesource.com/q/commit:f9678451d5ee7e6627ac57eb753de092caa076d2)
Merged-In: Iec48ef375eb1c498bc13da82d5d8355be58ba0ff
Change-Id: Iec48ef375eb1c498bc13da82d5d8355be58ba0ff
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/DefaultSpecialEffectsController.kt b/fragment/fragment/src/main/java/androidx/fragment/app/DefaultSpecialEffectsController.kt
index 92eb9d9..9dd1719 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/DefaultSpecialEffectsController.kt
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/DefaultSpecialEffectsController.kt
@@ -338,6 +338,13 @@
if (sharedElementNameMapping.isEmpty()) {
// We couldn't find any valid shared element mappings, so clear out
// the shared element transition information entirely
+ Log.i(FragmentManager.TAG,
+ "Ignoring shared elements transition $sharedElementTransition between " +
+ "$firstOut and $lastIn as there are no matching elements " +
+ "in both the entering and exiting fragment. In order to run a " +
+ "SharedElementTransition, both fragments involved must have the " +
+ "element."
+ )
sharedElementTransition = null
sharedElementFirstOutViews.clear()
sharedElementLastInViews.clear()
@@ -739,6 +746,16 @@
}
return
}
+ if (transitioning && sharedElementTransition != null && !isSeekingSupported) {
+ Log.i(FragmentManager.TAG,
+ "Ignoring shared elements transition $sharedElementTransition between " +
+ "$firstOut and $lastIn as neither fragment has set a Transition. In " +
+ "order to run a SharedElementTransition, you must also set either an " +
+ "enter or exit transition on a fragment involved in the transaction. The " +
+ "sharedElementTransition will run after the back gesture has been " +
+ "committed."
+ )
+ }
if (isSeekingSupported && transitioning) {
// We need to set the listener before we create the controller, but we need the
// controller to do the desired cancel behavior (animateToStart). So we use this