diff --git a/OsmAnd/src/net/osmand/plus/api/AudioFocusHelperImpl.java b/OsmAnd/src/net/osmand/plus/api/AudioFocusHelperImpl.java index 7b28353a08..2be1d4b168 100644 --- a/OsmAnd/src/net/osmand/plus/api/AudioFocusHelperImpl.java +++ b/OsmAnd/src/net/osmand/plus/api/AudioFocusHelperImpl.java @@ -19,31 +19,18 @@ public class AudioFocusHelperImpl implements AudioManager.OnAudioFocusChangeList private static final Log log = PlatformUtil.getLog(AudioFocusHelperImpl.class); @Override - public boolean requestFocus(Context context, int streamType) - { + public boolean requestFocus(Context context, int streamType) { 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, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK); - } - else - { - return true; - } + return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this, streamType, + ((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get()? + AudioManager.AUDIOFOCUS_GAIN_TRANSIENT: + AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK ); } @Override public boolean abandonFocus(Context context, int streamType) { - AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); - if (((OsmandApplication) context.getApplicationContext()).getSettings().INTERRUPT_MUSIC.get()) - { - return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this); - } - else - { - return true; - } + return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this); } @Override @@ -54,4 +41,4 @@ public class AudioFocusHelperImpl implements AudioManager.OnAudioFocusChangeList // reason to change this strategy. log.error("MediaCommandPlayerImpl.onAudioFocusChange(): Unexpected audio focus change: " + focusChange); } -} \ No newline at end of file +}