From 4541db3541e5d27e120b9f94de0d29896f35201f Mon Sep 17 00:00:00 2001 From: samrobinson Date: Wed, 28 Dec 2022 19:40:51 +0000 Subject: [PATCH] Deprecated onTransformationError methods are not called. When a listener method is deprecated, the new method should (by default) called through to the deprecated one. This is because any class that implements the method that is now deprecated needs to still receive that callback. It appears when onTransformationError(MediaItem, Exception) was deprecated in favour of onTransformationError(MediaItem, TransformationException), this deprecation was the wrong way round, and the newer callback - onTransformationError(MediaItem, TransformationResult, TransformationException) continued this mistake. This CL now corrects this. PiperOrigin-RevId: 498221504 --- .../androidx/media3/transformer/Transformer.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java index 756d1f52ad..338e990f0e 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java @@ -498,10 +498,9 @@ public final class Transformer { * Called when the transformation is completed successfully. * * @param inputMediaItem The {@link MediaItem} for which the transformation is completed. - * @param transformationResult The {@link TransformationResult} of the transformation. + * @param result The {@link TransformationResult} of the transformation. */ - default void onTransformationCompleted( - MediaItem inputMediaItem, TransformationResult transformationResult) { + default void onTransformationCompleted(MediaItem inputMediaItem, TransformationResult result) { onTransformationCompleted(inputMediaItem); } @@ -510,9 +509,7 @@ public final class Transformer { * TransformationException)}. */ @Deprecated - default void onTransformationError(MediaItem inputMediaItem, Exception exception) { - onTransformationError(inputMediaItem, (TransformationException) exception); - } + default void onTransformationError(MediaItem inputMediaItem, Exception exception) {} /** * @deprecated Use {@link #onTransformationError(MediaItem, TransformationResult, @@ -521,7 +518,7 @@ public final class Transformer { @Deprecated default void onTransformationError( MediaItem inputMediaItem, TransformationException exception) { - onTransformationError(inputMediaItem, new TransformationResult.Builder().build(), exception); + onTransformationError(inputMediaItem, (Exception) exception); } /** @@ -532,7 +529,9 @@ public final class Transformer { * @param exception The {@link TransformationException} describing the exception. */ default void onTransformationError( - MediaItem inputMediaItem, TransformationResult result, TransformationException exception) {} + MediaItem inputMediaItem, TransformationResult result, TransformationException exception) { + onTransformationError(inputMediaItem, exception); + } /** * Called when fallback to an alternative {@link TransformationRequest} is necessary to comply