From 3170e1ce716747a243987b878f7a2a7f33f4ed8c Mon Sep 17 00:00:00 2001 From: Eric Frohnhoefer Date: Fri, 30 Dec 2022 02:22:39 -0800 Subject: [PATCH] Fix auto play when swiping between attachments (#3077) * Fix auto play when swiping between attachments Fixes an issue where attachment doesn't autoplay when swiping left/right from initial attachment. Fixes #3066 * Fix lint error for wild card imports --- .../tusky/fragment/ViewVideoFragment.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt index 28991c26..566aa647 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewVideoFragment.kt @@ -66,19 +66,21 @@ class ViewVideoFragment : ViewMediaFragment() { videoActionsListener = context as VideoActionsListener } - override fun setUserVisibleHint(isVisibleToUser: Boolean) { - // Start/pause/resume video playback as fragment is shown/hidden - super.setUserVisibleHint(isVisibleToUser) - if (_binding == null) { - return - } + override fun onResume() { + super.onResume() - if (isVisibleToUser) { + if (_binding != null) { if (mediaActivity.isToolbarVisible) { handler.postDelayed(hideToolbar, TOOLBAR_HIDE_DELAY_MS) } binding.videoView.start() - } else { + } + } + + override fun onPause() { + super.onPause() + + if (_binding != null) { handler.removeCallbacks(hideToolbar) binding.videoView.pause() mediaController.hide() @@ -161,9 +163,6 @@ class ViewVideoFragment : ViewMediaFragment() { binding.progressBar.hide() mp.isLooping = true - if (requireArguments().getBoolean(ARG_START_POSTPONED_TRANSITION)) { - binding.videoView.start() - } } if (requireArguments().getBoolean(ARG_START_POSTPONED_TRANSITION)) {