mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00: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 4087a011e2)
This commit is contained in:
parent
bc829695bc
commit
7d3375c6ec
2 changed files with 13 additions and 6 deletions
|
|
@ -25,6 +25,11 @@
|
||||||
`Subtitle.getEventTime` if a subtitle file contains no cues.
|
`Subtitle.getEventTime` if a subtitle file contains no cues.
|
||||||
* SubRip: Add support for UTF-16 files if they start with a byte order
|
* SubRip: Add support for UTF-16 files if they start with a byte order
|
||||||
mark.
|
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:
|
* Session:
|
||||||
* Add abstract `SimpleBasePlayer` to help implement the `Player` interface
|
* Add abstract `SimpleBasePlayer` to help implement the `Player` interface
|
||||||
for custom players.
|
for custom players.
|
||||||
|
|
|
||||||
|
|
@ -887,8 +887,8 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
/**
|
/**
|
||||||
* Sets the {@link PlayerControlView.VisibilityListener}.
|
* Sets the {@link PlayerControlView.VisibilityListener}.
|
||||||
*
|
*
|
||||||
* <p>Removes any listener set by {@link
|
* <p>If {@code listener} is non-null then any listener set by {@link
|
||||||
* #setControllerVisibilityListener(PlayerControlView.VisibilityListener)}.
|
* #setControllerVisibilityListener(PlayerControlView.VisibilityListener)} is removed.
|
||||||
*
|
*
|
||||||
* @param listener The listener to be notified about visibility changes, or null to remove the
|
* @param listener The listener to be notified about visibility changes, or null to remove the
|
||||||
* current listener.
|
* current listener.
|
||||||
|
|
@ -896,14 +896,16 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
@SuppressWarnings("deprecation") // Clearing the legacy listener.
|
@SuppressWarnings("deprecation") // Clearing the legacy listener.
|
||||||
public void setControllerVisibilityListener(@Nullable ControllerVisibilityListener listener) {
|
public void setControllerVisibilityListener(@Nullable ControllerVisibilityListener listener) {
|
||||||
this.controllerVisibilityListener = listener;
|
this.controllerVisibilityListener = listener;
|
||||||
|
if (listener != null) {
|
||||||
setControllerVisibilityListener((PlayerControlView.VisibilityListener) null);
|
setControllerVisibilityListener((PlayerControlView.VisibilityListener) null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link PlayerControlView.VisibilityListener}.
|
* Sets the {@link PlayerControlView.VisibilityListener}.
|
||||||
*
|
*
|
||||||
* <p>Removes any listener set by {@link
|
* <p>If {@code listener} is non-null then any listener set by {@link
|
||||||
* #setControllerVisibilityListener(ControllerVisibilityListener)}.
|
* #setControllerVisibilityListener(ControllerVisibilityListener)} is removed.
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link #setControllerVisibilityListener(ControllerVisibilityListener)} instead.
|
* @deprecated Use {@link #setControllerVisibilityListener(ControllerVisibilityListener)} instead.
|
||||||
*/
|
*/
|
||||||
|
|
@ -923,9 +925,9 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
this.legacyControllerVisibilityListener = listener;
|
this.legacyControllerVisibilityListener = listener;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
controller.addVisibilityListener(listener);
|
controller.addVisibilityListener(listener);
|
||||||
}
|
|
||||||
setControllerVisibilityListener((ControllerVisibilityListener) null);
|
setControllerVisibilityListener((ControllerVisibilityListener) null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link FullscreenButtonClickListener}.
|
* Sets the {@link FullscreenButtonClickListener}.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue