mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix recursive loop when registering controller visibility listeners
There are two overloads of this method due to a type 'rename' from `PlayerControlView.VisibilityListener` to `PlayerView.ControllerVisibilityListener`. Currently when you call one overload it passes `null` to the other one (to clear the other listener). Unfortunately this results in it clearing itself, because it receives a null call back! This change tweaks the documentation to clarify that the 'other' listener is only cleared if you pass a non-null listener in. This solves the recursive problem, and allows the 'legacy' visibility listener to be successfully registered. Issue: androidx/media#229 #minor-release PiperOrigin-RevId: 496876397 (cherry picked from commit 4087a011e21aba2c27e3ae890f74a65812c6f4ce)
This commit is contained in:
parent
bc829695bc
commit
7d3375c6ec
@ -25,6 +25,11 @@
|
||||
`Subtitle.getEventTime` if a subtitle file contains no cues.
|
||||
* SubRip: Add support for UTF-16 files if they start with a byte order
|
||||
mark.
|
||||
* UI:
|
||||
* Fix the deprecated
|
||||
`PlayerView.setControllerVisibilityListener(PlayerControlView.VisibilityListener)`
|
||||
to ensure visibility changes are passed to the registered listener
|
||||
([#229](https://github.com/androidx/media/issues/229)).
|
||||
* Session:
|
||||
* Add abstract `SimpleBasePlayer` to help implement the `Player` interface
|
||||
for custom players.
|
||||
|
@ -887,8 +887,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
/**
|
||||
* Sets the {@link PlayerControlView.VisibilityListener}.
|
||||
*
|
||||
* <p>Removes any listener set by {@link
|
||||
* #setControllerVisibilityListener(PlayerControlView.VisibilityListener)}.
|
||||
* <p>If {@code listener} is non-null then any listener set by {@link
|
||||
* #setControllerVisibilityListener(PlayerControlView.VisibilityListener)} is removed.
|
||||
*
|
||||
* @param listener The listener to be notified about visibility changes, or null to remove the
|
||||
* current listener.
|
||||
@ -896,14 +896,16 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
@SuppressWarnings("deprecation") // Clearing the legacy listener.
|
||||
public void setControllerVisibilityListener(@Nullable ControllerVisibilityListener listener) {
|
||||
this.controllerVisibilityListener = listener;
|
||||
setControllerVisibilityListener((PlayerControlView.VisibilityListener) null);
|
||||
if (listener != null) {
|
||||
setControllerVisibilityListener((PlayerControlView.VisibilityListener) null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link PlayerControlView.VisibilityListener}.
|
||||
*
|
||||
* <p>Removes any listener set by {@link
|
||||
* #setControllerVisibilityListener(ControllerVisibilityListener)}.
|
||||
* <p>If {@code listener} is non-null then any listener set by {@link
|
||||
* #setControllerVisibilityListener(ControllerVisibilityListener)} is removed.
|
||||
*
|
||||
* @deprecated Use {@link #setControllerVisibilityListener(ControllerVisibilityListener)} instead.
|
||||
*/
|
||||
@ -923,8 +925,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||
this.legacyControllerVisibilityListener = listener;
|
||||
if (listener != null) {
|
||||
controller.addVisibilityListener(listener);
|
||||
setControllerVisibilityListener((ControllerVisibilityListener) null);
|
||||
}
|
||||
setControllerVisibilityListener((ControllerVisibilityListener) null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user