diff --git a/Kuroba/app/build.gradle b/Kuroba/app/build.gradle index e7b5ef0f7f..05ca58f568 100644 --- a/Kuroba/app/build.gradle +++ b/Kuroba/app/build.gradle @@ -16,8 +16,8 @@ android { //bump the MINOR (YY) version when there are compatible changes between versions (ie database changes) //or if there are big application level changes like tearing out/adding major features //bump the PATCH (ZZ) version otherwise, for anything small - versionCode 40201 - versionName "v4.2.1" + versionCode 40202 + versionName "v4.2.2" applicationId "com.github.adamantcheese.chan" //this is your update endpoint, change it to your repository diff --git a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/view/MultiImageView.java b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/view/MultiImageView.java index 966cc575d9..2a3a979d14 100644 --- a/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/view/MultiImageView.java +++ b/Kuroba/app/src/main/java/com/github/adamantcheese/chan/ui/view/MultiImageView.java @@ -20,6 +20,8 @@ import android.content.Intent; import android.graphics.Color; import android.graphics.PorterDuff; +import android.os.Handler; +import android.os.Looper; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; @@ -54,6 +56,8 @@ import java.io.File; import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import javax.inject.Inject; @@ -62,7 +66,6 @@ import static com.github.adamantcheese.chan.Chan.inject; import static com.github.adamantcheese.chan.utils.AndroidUtils.getAppContext; -import static com.github.adamantcheese.chan.utils.AndroidUtils.runOnUiThread; public class MultiImageView extends FrameLayout implements View.OnClickListener, AudioListener, LifecycleObserver { public enum Mode { @@ -91,6 +94,7 @@ public enum Mode { private FileCacheDownloader videoRequest; private SimpleExoPlayer exoPlayer; + private ExecutorService threadPool = Executors.newCachedThreadPool(); private boolean backgroundToggle; @@ -391,21 +395,24 @@ private void setVideo(String videoUrl) { } private void openVideoInternalStream(String videoUrl) { - runOnUiThread(() -> fileCache.createMediaSource(videoUrl, source -> { - PlayerView exoVideoView = new PlayerView(getContext()); - exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext()); - exoVideoView.setPlayer(exoPlayer); - - exoPlayer.setRepeatMode(ChanSettings.videoAutoLoop.get() ? - Player.REPEAT_MODE_ALL : Player.REPEAT_MODE_OFF); - - exoPlayer.prepare(source); - exoPlayer.addAudioListener(MultiImageView.this); - - addView(exoVideoView); - exoPlayer.setPlayWhenReady(true); - onModeLoaded(Mode.MOVIE, exoVideoView); - callback.onVideoLoaded(MultiImageView.this); + threadPool.execute(() -> fileCache.createMediaSource(videoUrl, source -> { + Handler h = new Handler(Looper.getMainLooper()); + h.post(() -> { + PlayerView exoVideoView = new PlayerView(getContext()); + exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext()); + exoVideoView.setPlayer(exoPlayer); + + exoPlayer.setRepeatMode(ChanSettings.videoAutoLoop.get() ? + Player.REPEAT_MODE_ALL : Player.REPEAT_MODE_OFF); + + exoPlayer.prepare(source); + exoPlayer.addAudioListener(MultiImageView.this); + + addView(exoVideoView); + exoPlayer.setPlayWhenReady(true); + onModeLoaded(Mode.MOVIE, exoVideoView); + callback.onVideoLoaded(MultiImageView.this); + }); })); }