-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differ AudioManager retrieval to whenever AudioFocusManagement is req… #1616
Conversation
@@ -455,6 +453,13 @@ private void executePlayerCommand(@PlayerCommand int playerCommand) { | |||
} | |||
} | |||
|
|||
private AudioManager getAudioManager() { | |||
if (audioManager == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIt: you can use Guava's Suppliers.memoize
for this, to avoid manually needing to check for null, so change private final AudioManager audioManager;
above to private final Supplier<AudioManager> audioManager;
, change the instantiation to:
this.audioManager =
Suppliers.memoize(() -> checkNotNull(
(AudioManager) context.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)));
And then change the usage sites from audioManager
to audioManager.get()
Maybe change the field name to audioManagerSupplier
too - up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Will change accordingly
I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks! |
…uired