Update AudioFocusHelperImpl.java

This commit is contained in:
vshcherb 2014-11-19 17:43:09 +01:00
parent 67d418f2c3
commit 85110242ad

View file

@ -19,31 +19,18 @@ public class AudioFocusHelperImpl implements AudioManager.OnAudioFocusChangeList
private static final Log log = PlatformUtil.getLog(AudioFocusHelperImpl.class); private static final Log log = PlatformUtil.getLog(AudioFocusHelperImpl.class);
@Override @Override
public boolean requestFocus(Context context, int streamType) public boolean requestFocus(Context context, int streamType) {
{
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get()) return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this, streamType,
{ ((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get()?
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this, streamType, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK); AudioManager.AUDIOFOCUS_GAIN_TRANSIENT:
} AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK );
else
{
return true;
}
} }
@Override @Override
public boolean abandonFocus(Context context, int streamType) public boolean abandonFocus(Context context, int streamType)
{ {
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this);
if (((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get())
{
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this);
}
else
{
return true;
}
} }
@Override @Override