Skip to content

Commit 661c6a1

Browse files
dsn5fthunterstich
authored andcommitted
[Motion] Added extra transition background fade duration to MaterialContainerTransformSharedElementCallback to prevent extra Activity transition from happening
Resolves #1433 Mentioned in #1344 PiperOrigin-RevId: 321550602 (cherry picked from commit 889fca5)
1 parent 3101ef0 commit 661c6a1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/java/com/google/android/material/transition/platform/MaterialContainerTransformSharedElementCallback.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
@RequiresApi(VERSION_CODES.LOLLIPOP)
5252
public class MaterialContainerTransformSharedElementCallback extends SharedElementCallback {
5353

54+
private static final int BACKGROUND_FADE_EXTRA_DURATION = 60;
55+
5456
@Nullable private static WeakReference<View> capturedSharedElement;
5557

5658
private boolean entering = true;
@@ -294,11 +296,14 @@ private static void restoreWindowBackground(Window window) {
294296
}
295297

296298
/**
297-
* When using a transparent window background, make sure that the background fade duration is as
298-
* long as the transform's duration. This will help to avoid a black background visual artifact.
299+
* When using a transparent window background, make sure that the background fade duration is at
300+
* least as long as the transform's duration. This will help to avoid a black background visual
301+
* artifact and an extra transition from happening after the container transform on certain API
302+
* levels.
299303
*/
300304
private static void updateBackgroundFadeDuration(
301305
Window window, MaterialContainerTransform transform) {
302-
window.setTransitionBackgroundFadeDuration(transform.getDuration());
306+
window.setTransitionBackgroundFadeDuration(
307+
transform.getDuration() + BACKGROUND_FADE_EXTRA_DURATION);
303308
}
304309
}

0 commit comments

Comments
 (0)