Class ListenerSet<T extends @NonNull Object>
- java.lang.Object
-
- com.google.android.exoplayer2.util.ListenerSet<T>
-
- Type Parameters:
T- The listener type.
@Deprecated public final class ListenerSet<T extends @NonNull Object> extends Object
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
Looperpassed to the constructor unless indicated otherwise.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceListenerSet.Event<T>Deprecated.An event sent to a listener.static interfaceListenerSet.IterationFinishedEvent<T>Deprecated.An event sent to a listener when all other events sent during oneLoopermessage queue iteration were handled by the listener.
-
Constructor Summary
Constructors Constructor Description ListenerSet(Looper looper, Clock clock, ListenerSet.IterationFinishedEvent<T> iterationFinishedEvent)Deprecated.Creates a new listener set.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(T listener)Deprecated.Adds a listener to the set.voidclear()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.voidflushEvents()Deprecated.Notifies listeners of events previously enqueued withqueueEvent(int, Event).voidqueueEvent(int eventFlag, ListenerSet.Event<T> event)Deprecated.Adds an event that is sent to the listeners whenflushEvents()is called.voidrelease()Deprecated.Releases the set of listeners immediately.voidremove(T listener)Deprecated.Removes a listener from the set.voidsendEvent(int eventFlag, ListenerSet.Event<T> event)Deprecated.voidsetThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread)Deprecated.Do not use this method and ensure all calls are made from the correct thread.intsize()Deprecated.Returns the number of added listeners.
-
-
-
Constructor Detail
-
ListenerSet
public ListenerSet(Looper looper, Clock clock, ListenerSet.IterationFinishedEvent<T> iterationFinishedEvent)
Deprecated.Creates a new listener set.- Parameters:
looper- ALooperused to call listeners on. The sameLoopermust be used to call all other methods of this class unless indicated otherwise.clock- AClock.iterationFinishedEvent- AnListenerSet.IterationFinishedEventsent when all other events sent during oneLoopermessage queue iteration were handled by the listeners.
-
-
Method Detail
-
copy
@CheckResult public ListenerSet<T> copy(Looper looper, ListenerSet.IterationFinishedEvent<T> iterationFinishedEvent)
Deprecated.Copies the listener set.This method can be called from any thread.
- Parameters:
looper- The newLooperfor the copied listener set.iterationFinishedEvent- The newListenerSet.IterationFinishedEventsent when all other events sent during oneLoopermessage queue iteration were handled by the listeners.- Returns:
- The copied listener set.
-
copy
@CheckResult public ListenerSet<T> copy(Looper looper, Clock clock, ListenerSet.IterationFinishedEvent<T> iterationFinishedEvent)
Deprecated.Copies the listener set.This method can be called from any thread.
- Parameters:
looper- The newLooperfor the copied listener set.clock- The newClockfor the copied listener set.iterationFinishedEvent- The newListenerSet.IterationFinishedEventsent when all other events sent during oneLoopermessage queue iteration were handled by the listeners.- Returns:
- The copied listener set.
-
add
public void add(T 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.
-
remove
public void remove(T listener)
Deprecated.Removes a listener from the set.If the listener is not present, nothing happens.
- Parameters:
listener- The listener to be removed.
-
clear
public void clear()
Deprecated.Removes all listeners from the set.
-
size
public int size()
Deprecated.Returns the number of added listeners.
-
queueEvent
public void queueEvent(int eventFlag, ListenerSet.Event<T> event)Deprecated.Adds an event that is sent to the listeners whenflushEvents()is called.- Parameters:
eventFlag- An integer indicating the type of the event, orC.INDEX_UNSETto report this event without flag.event- The event.
-
flushEvents
public void flushEvents()
Deprecated.Notifies listeners of events previously enqueued withqueueEvent(int, Event).
-
sendEvent
public void sendEvent(int eventFlag, ListenerSet.Event<T> event)Deprecated.- Parameters:
eventFlag- An integer flag indicating the type of the event, orC.INDEX_UNSETto report this event without flag.event- The event.
-
release
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.
-
setThrowsWhenUsingWrongThread
@Deprecated 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.
-
-