Class ListenerSet<T extends @NonNull Object>

  • 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 Looper passed to the constructor unless indicated otherwise.

    • Constructor Detail

    • Method Detail

      • 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 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.
      • 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 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.
      • flushEvents

        public void flushEvents()
        Deprecated.
        Notifies listeners of events previously enqueued with queueEvent(int, Event).
      • sendEvent

        public void sendEvent​(int eventFlag,
                              ListenerSet.Event<T> 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.
      • 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.