Commit 7d2a2aa2 by christosts Committed by bachinger

Override available commands in ForwardingPlayer

This change adds an API in the ForwardingPlayer to disable commands.
This is affecting what Player.isCommandAvailable() returns as
well as what is being advertised from the
EventListener.onAvailableCommandsChanged() callback.

For the callback case, the ForwardingPlayer needs to intercept the
callback. It does so by wrapping registered EventListener and Listener
instances, which resulted in some boiler-plate code. In addition, there
is logic on the wrapped listeners to avoid triggering a queued callback
if all listeners have been removed in the meantime. This includes the
case where new listeners are added while callbacks scheduled for the
removed listeners are still pending.

PiperOrigin-RevId: 371139703
parent cdff4566
...@@ -37,6 +37,7 @@ dependencies { ...@@ -37,6 +37,7 @@ dependencies {
testImplementation 'com.google.truth:truth:' + truthVersion testImplementation 'com.google.truth:truth:' + truthVersion
testImplementation 'com.squareup.okhttp3:mockwebserver:' + mockWebServerVersion testImplementation 'com.squareup.okhttp3:mockwebserver:' + mockWebServerVersion
testImplementation 'org.robolectric:robolectric:' + robolectricVersion testImplementation 'org.robolectric:robolectric:' + robolectricVersion
testImplementation project(modulePrefix + 'library-core')
testImplementation project(modulePrefix + 'testutils') testImplementation project(modulePrefix + 'testutils')
} }
......
...@@ -155,6 +155,11 @@ public final class ListenerSet<T> { ...@@ -155,6 +155,11 @@ public final class ListenerSet<T> {
} }
} }
/** Returns the number of added listeners. */
public int size() {
return listeners.size();
}
/** /**
* Adds an event that is sent to the listeners when {@link #flushEvents} is called. * Adds an event that is sent to the listeners when {@link #flushEvents} is called.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment