Removing @CallSuper from [add,remove]Listener of ForwardingListener.

PiperOrigin-RevId: 543373503
This commit is contained in:
Googler 2023-06-26 09:11:27 +00:00 committed by Tofunmi Adigun-Hameed
parent 81dfe9d4b4
commit 1fc49ce288

View File

@ -20,7 +20,6 @@ import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
import androidx.annotation.CallSuper;
import androidx.annotation.Nullable;
import androidx.media3.common.text.Cue;
import androidx.media3.common.text.CueGroup;
@ -51,13 +50,14 @@ public class ForwardingPlayer implements Player {
/**
* Calls {@link Player#addListener(Listener)} on the delegate.
*
* <p>Overrides of this method must delegate to {@code super.addListener} and not {@code
* delegate.addListener}, in order to ensure the correct {@link Player} instance is passed to
* {@link Player.Listener#onEvents(Player, Events)} (i.e. this forwarding instance, and not the
* <p>Overrides of this method must <strong>not</strong> directly call {@code
* delegate.addListener}. If the override wants to pass the {@link Player.Listener} instance to
* the delegate {@link Player}, it must do so by calling {@code super.addListener} instead. This
* ensures the correct {@link Player} instance is passed to {@link
* Player.Listener#onEvents(Player, Events)} (i.e. this forwarding instance, and not the
* underlying {@code delegate} instance).
*/
@Override
@CallSuper
public void addListener(Listener listener) {
player.addListener(new ForwardingListener(this, listener));
}
@ -65,12 +65,11 @@ public class ForwardingPlayer implements Player {
/**
* Calls {@link Player#removeListener(Listener)} on the delegate.
*
* <p>Overrides of this method must delegate to {@code super.removeListener} and not {@code
* delegate.removeListener}, in order to ensure the listener 'matches' the listener added via
* {@link #addListener} (otherwise the listener registered on the delegate won't be removed).
* <p>Overrides of this method must <strong>not</strong> directly call {@code
* delegate.removeListener}. If the override wants to pass the {@link Player.Listener} instance to
* the delegate {@link Player}, it must do so by calling {@code super.removeListener} instead.
*/
@Override
@CallSuper
public void removeListener(Listener listener) {
player.removeListener(new ForwardingListener(this, listener));
}