From 6c23e4238f575cbaffd3bdb57e02c8248b66c8db Mon Sep 17 00:00:00 2001 From: Alex Eyre <2012eyre@students.mggs.org> Date: Sat, 6 Oct 2018 15:32:32 +0000 Subject: [PATCH] Tidy code - Ran a code formatter to sort out my spacing - Refactored hasMediaPlayerAudioTracks(..) - Injected UserAgent rather than hardcoding a string --- .../floens/chan/ui/view/MultiImageView.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/ui/view/MultiImageView.java b/Clover/app/src/main/java/org/floens/chan/ui/view/MultiImageView.java index 702f26e73b..80d9c195de 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/view/MultiImageView.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/view/MultiImageView.java @@ -52,6 +52,7 @@ import org.floens.chan.core.cache.FileCacheDownloader; import org.floens.chan.core.cache.FileCacheListener; import org.floens.chan.core.cache.FileCacheProvider; +import org.floens.chan.core.di.UserAgentProvider; import org.floens.chan.core.model.PostImage; import org.floens.chan.core.settings.ChanSettings; import org.floens.chan.utils.AndroidUtils; @@ -80,6 +81,9 @@ public enum Mode { @Inject ImageLoader imageLoader; + @Inject + UserAgentProvider userAgent; + private ImageView playView; private PostImage postImage; @@ -178,8 +182,8 @@ public CustomScaleImageView findScaleImageView() { public void setVolume(boolean muted) { final float volume = muted ? 0f : 1f; - if(ChanSettings.videoUseExoplayer.get()){ - if(exoPlayer != null) { + if (ChanSettings.videoUseExoplayer.get()) { + if (exoPlayer != null) { exoPlayer.getAudioComponent().setVolume(volume); } } else { @@ -413,14 +417,14 @@ private void setVideoFile(final File file) { exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext()); exoVideoView.setPlayer(exoPlayer); DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getContext(), - Util.getUserAgent(getContext(),"Clover")); + Util.getUserAgent(getContext(), userAgent.getUserAgent())); MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory) .createMediaSource(android.net.Uri.fromFile(file)); exoPlayer.setRepeatMode(Player.REPEAT_MODE_ALL); //Repeat forever exoPlayer.prepare(videoSource); - callback.onVideoLoaded(this,hasMediaPlayerAudioTracks(exoPlayer)); + callback.onVideoLoaded(this, hasMediaPlayerAudioTracks(exoPlayer)); addView(exoVideoView); exoPlayer.setPlayWhenReady(true); } else { @@ -484,11 +488,7 @@ private boolean hasMediaPlayerAudioTracks(MediaPlayer mediaPlayer) { } private boolean hasMediaPlayerAudioTracks(ExoPlayer mediaPlayer) { - if(mediaPlayer.getAudioComponent() == null) { - return false; - } else { - return true; - } + return mediaPlayer.getAudioComponent() != null; } private void onVideoError() {