docs/doc/reference/com/google/android/exoplayer2/util/ListenerSet.html
Package com.google.android.exoplayer2.util
Type Parameters:T - The listener type.
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classListenerSet\<T extends @NonNull [Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")\>extends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
A set of listeners.
Events are guaranteed to arrive in the order in which they happened even if a new event is triggered recursively from another listener.
Events are also guaranteed to be only sent to the listeners registered at the time the event was enqueued and haven't been removed since.
All methods must be called on the Looper passed to the constructor unless indicated otherwise.
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| static interface | ListenerSet.Event<T> |
Deprecated.
An event sent to a listener.
|
| static interface | ListenerSet.IterationFinishedEvent<T> |
Deprecated.
An event sent to a listener when all other events sent during one Looper message queue iteration were handled by the listener.
|
Constructors | Constructor | Description |
| --- | --- |
| ListenerSet(Looper looper, Clock clock, ListenerSet.IterationFinishedEvent<T> iterationFinishedEvent) |
Deprecated.
Creates a new listener set. |
All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | add(T listener) |
Deprecated.
Adds a listener to the set.
|
| void | clear() |
Deprecated.
Removes all listeners from the set.
|
| ListenerSet<T> | copy(Looper looper, Clock clock, ListenerSet.IterationFinishedEvent<T> iterationFinishedEvent) |
Deprecated.
Copies the listener set.
|
| ListenerSet<T> | copy(Looper looper, ListenerSet.IterationFinishedEvent<T> iterationFinishedEvent) |
Deprecated.
Copies the listener set.
|
| void | flushEvents() |
Deprecated.
Notifies listeners of events previously enqueued with queueEvent(int, Event).
|
| void | queueEvent(int eventFlag, ListenerSet.Event<T> event) |
Deprecated.
Adds an event that is sent to the listeners when flushEvents() is called.
|
| void | release() |
Deprecated.
Releases the set of listeners immediately.
|
| void | remove(T listener) |
Deprecated.
Removes a listener from the set.
|
| void | sendEvent(int eventFlag, ListenerSet.Event<T> event) |
Deprecated.
Queues a single event and immediately flushes the event queue to notify all listeners.
|
| void | setThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread) |
Deprecated.
Do not use this method and ensure all calls are made from the correct thread.
|
| int | size() |
Deprecated.
Returns the number of added listeners. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public ListenerSet([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")looper,[Clock](Clock.html "interface in com.google.android.exoplayer2.util")clock,[ListenerSet.IterationFinishedEvent](ListenerSet.IterationFinishedEvent.html "interface in com.google.android.exoplayer2.util")<[T](ListenerSet.html "type parameter in ListenerSet")> iterationFinishedEvent)
Deprecated.
Creates a new listener set.
Parameters:looper - A Looper used to call listeners on. The same Looper must be used to call all other methods of this class unless indicated otherwise.clock - A Clock.iterationFinishedEvent - An ListenerSet.IterationFinishedEvent sent when all other events sent during one Looper message queue iteration were handled by the listeners.
-
@CheckResult
public[ListenerSet](ListenerSet.html "class in com.google.android.exoplayer2.util")<[T](ListenerSet.html "type parameter in ListenerSet")> copy([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")looper,[ListenerSet.IterationFinishedEvent](ListenerSet.IterationFinishedEvent.html "interface in com.google.android.exoplayer2.util")<[T](ListenerSet.html "type parameter in ListenerSet")> iterationFinishedEvent)
Deprecated.
Copies the listener set.
This method can be called from any thread.
Parameters:looper - The new Looper for the copied listener set.iterationFinishedEvent - The new ListenerSet.IterationFinishedEvent sent when all other events sent during one Looper message queue iteration were handled by the listeners.Returns:The copied listener set.
-
@CheckResult
public[ListenerSet](ListenerSet.html "class in com.google.android.exoplayer2.util")<[T](ListenerSet.html "type parameter in ListenerSet")> copy([Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")looper,[Clock](Clock.html "interface in com.google.android.exoplayer2.util")clock,[ListenerSet.IterationFinishedEvent](ListenerSet.IterationFinishedEvent.html "interface in com.google.android.exoplayer2.util")<[T](ListenerSet.html "type parameter in ListenerSet")> iterationFinishedEvent)
Deprecated.
Copies the listener set.
This method can be called from any thread.
Parameters:looper - The new Looper for the copied listener set.clock - The new Clock for the copied listener set.iterationFinishedEvent - The new ListenerSet.IterationFinishedEvent sent when all other events sent during one Looper message queue iteration were handled by the listeners.Returns:The copied listener set.
-
public void add([T](ListenerSet.html "type parameter in ListenerSet")listener)
Deprecated.
Adds a listener to the set.
If a listener is already present, it will not be added again.
This method can be called from any thread.
Parameters:listener - The listener to be added.
-
public void remove([T](ListenerSet.html "type parameter in ListenerSet")listener)
Deprecated.
Removes a listener from the set.
If the listener is not present, nothing happens.
Parameters:listener - The listener to be removed.
-
public void clear()
Deprecated.
Removes all listeners from the set.
-
public int size()
Deprecated.
Returns the number of added listeners.
-
public void queueEvent(int eventFlag,[ListenerSet.Event](ListenerSet.Event.html "interface in com.google.android.exoplayer2.util")<[T](ListenerSet.html "type parameter in ListenerSet")> event)
Deprecated.
Adds an event that is sent to the listeners when flushEvents() is called.
Parameters:eventFlag - An integer indicating the type of the event, or C.INDEX_UNSET to report this event without flag.event - The event.
-
public void flushEvents()
Deprecated.
Notifies listeners of events previously enqueued with queueEvent(int, Event).
-
public void sendEvent(int eventFlag,[ListenerSet.Event](ListenerSet.Event.html "interface in com.google.android.exoplayer2.util")<[T](ListenerSet.html "type parameter in ListenerSet")> event)
Deprecated.
Queues a single event and immediately flushes the event queue to notify all listeners.
Parameters:eventFlag - An integer flag indicating the type of the event, or C.INDEX_UNSET to report this event without flag.event - The event.
-
public void release()
Deprecated.
Releases the set of listeners immediately.
This will ensure no events are sent to any listener after this method has been called.
-
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public void setThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread)
Deprecated. Do not use this method and ensure all calls are made from the correct thread.
Sets whether methods throw when using the wrong thread.
Do not use this method unless to support legacy use cases.
Parameters:throwsWhenUsingWrongThread - Whether to throw when using the wrong thread.