You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am implementing a custom Player in Kotlin, based on SimpleBasePlayer. I'd like to delegate some functionality to other classes outside of the class extending SimpleBasePlayer. Those classes are not capable of contributing to SimpleBasePlayer.State updates in a reasonable manner—via SimpleBasePlayer.State.Builder—because SimpleBasePlayer.State is protected. Everything relevant to updating State has to go inside a single giant monolith with objects, inner classes, and nested classes. The file has 1000+ lines.
For example, I have an AudioFocusChangeListener class that contributes to changing State. I am unable to move it outside the SimpleBasePlayer child class.
Proposed solution
Make SimpleBasePlayer.State public, which will in turn permit usage of SimpleBasePlayer.State.Builder outside of child classes of SimpleBasePlayer.
For example, this would support passing a lambda with a State.Builder argument around. The SimpleBasePlayer child can remain responsible for applying the updates.
state, getState(), and invalidateState() can remain private or protected, which is what actually matters.
Alternatives considered
Move AudioFocusChangeListener class back into the giant monolith.
The text was updated successfully, but these errors were encountered:
I agree this makes sense. We were initially hesitant because the idea is to build the state on demand in getState to match the backend implementation of the actual player, so you'd never need to pass around or store this State anywhere. But this is of course a bit too simplistic for actual usages :)
This ensures it's easier to handle these State updates in other
helper classes if needed.
Issue: #2128
PiperOrigin-RevId: 728264396
(cherry picked from commit f1c62c1)
Use case description
I am implementing a custom Player in Kotlin, based on SimpleBasePlayer. I'd like to delegate some functionality to other classes outside of the class extending SimpleBasePlayer. Those classes are not capable of contributing to SimpleBasePlayer.State updates in a reasonable manner—via SimpleBasePlayer.State.Builder—because SimpleBasePlayer.State is protected. Everything relevant to updating State has to go inside a single giant monolith with objects, inner classes, and nested classes. The file has 1000+ lines.
For example, I have an AudioFocusChangeListener class that contributes to changing State. I am unable to move it outside the SimpleBasePlayer child class.
Proposed solution
Make SimpleBasePlayer.State public, which will in turn permit usage of SimpleBasePlayer.State.Builder outside of child classes of SimpleBasePlayer.
For example, this would support passing a lambda with a State.Builder argument around. The SimpleBasePlayer child can remain responsible for applying the updates.
state
,getState()
, andinvalidateState()
can remain private or protected, which is what actually matters.Alternatives considered
Move AudioFocusChangeListener class back into the giant monolith.
The text was updated successfully, but these errors were encountered: